diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2015-08-19 16:56:49 +0200 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2015-08-19 17:18:37 +0200 |
commit | 35fbad47d7e74faa7eaa87ade534a9fb10df6d36 (patch) | |
tree | e7171e192cad53465400d902dd6345c1e8e5a30c /mediagoblin/db/mixin.py | |
parent | c9f6afe291e76f4f0deb6467b32ba34861b850f3 (diff) | |
download | mediagoblin-35fbad47d7e74faa7eaa87ade534a9fb10df6d36.tar.lz mediagoblin-35fbad47d7e74faa7eaa87ade534a9fb10df6d36.tar.xz mediagoblin-35fbad47d7e74faa7eaa87ade534a9fb10df6d36.zip |
Change structure of MediaEntry and add migration
This makes the changes needed for federating MediaEntry objects as well
as adding the migration and necessary methods to get the public_id just
in time (JIT).
Diffstat (limited to 'mediagoblin/db/mixin.py')
-rw-r--r-- | mediagoblin/db/mixin.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 88df1f6b..ab6de230 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -196,6 +196,25 @@ class MediaEntryMixin(GenerateSlugMixin): media=self.slug_or_id, **extra_args) + def get_public_id(self, request): + """ Returns the public_id of the MediaEntry + + If the MediaEntry has no public ID one will be produced from the + current request. + """ + if self.public_id is None: + self.public_id = request.urlgen( + "mediagoblin.api.object", + object_type=self.object_type, + id=self.id, + qualified=True + ) + # We need to ensure this ID is reused once we've given it out. + self.save() + + return self.public_id + + @property def thumb_url(self): """Return the thumbnail URL (for usage in templates) |