diff options
author | Jessica Tallon <jessica@megworld.co.uk> | 2014-08-05 22:04:50 +0100 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-08-18 10:51:32 -0500 |
commit | 9246a6ba89ab22a07e06b673e9eb0f135d2079a6 (patch) | |
tree | 0fd4eb1bd6819540007cd326c1ac4dc3d198eb9b /mediagoblin/db/models.py | |
parent | 32ff6f4dc06c91d452afa717eb3198cf746c2bf1 (diff) | |
download | mediagoblin-9246a6ba89ab22a07e06b673e9eb0f135d2079a6.tar.lz mediagoblin-9246a6ba89ab22a07e06b673e9eb0f135d2079a6.tar.xz mediagoblin-9246a6ba89ab22a07e06b673e9eb0f135d2079a6.zip |
Tidy up federation code and add tests to cover more of the APIs
Diffstat (limited to 'mediagoblin/db/models.py')
-rw-r--r-- | mediagoblin/db/models.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 932ba074..b910e522 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -439,18 +439,11 @@ class MediaEntry(Base, MediaEntryMixin): def serialize(self, request, show_comments=True): """ Unserialize MediaEntry to object """ author = self.get_uploader - url = request.urlgen( - "mediagoblin.user_pages.media_home", - user=author.username, - media=self.slug, - qualified=True - ) - context = { "id": self.id, "author": author.serialize(request), "objectType": self.objectType, - "url": url, + "url": self.url_for_self(request.urlgen), "image": { "url": request.host_url + self.thumb_url[1:], }, @@ -683,13 +676,13 @@ class MediaComment(Base, MediaCommentMixin): # Validate inReplyTo has ID if "id" not in data["inReplyTo"]: return False - + # Validate that the ID is correct try: media_id = int(data["inReplyTo"]["id"]) except ValueError: return False - + media = MediaEntry.query.filter_by(id=media_id).first() if media is None: return False |