aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db
diff options
context:
space:
mode:
authorRomain Porte <microjoe@microjoe.org>2017-11-11 19:23:30 +0100
committerBoris Bobrov <breton@cynicmansion.ru>2017-11-12 00:07:53 +0300
commit6810ba03d4c00de862573ff12b4203be809ac371 (patch)
tree9a272c1f61e4beb974aecc119ff50f0324950688 /mediagoblin/db
parentda7c027f1c3ccc5ef819da9ffaf04157b03d8aa8 (diff)
downloadmediagoblin-6810ba03d4c00de862573ff12b4203be809ac371.tar.lz
mediagoblin-6810ba03d4c00de862573ff12b4203be809ac371.tar.xz
mediagoblin-6810ba03d4c00de862573ff12b4203be809ac371.zip
Added tags in API (view them and edit them)
Diffstat (limited to 'mediagoblin/db')
-rw-r--r--mediagoblin/db/models.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index f4644b9f..3b85b07a 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -43,6 +43,7 @@ from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, \
from mediagoblin.tools.files import delete_media_files
from mediagoblin.tools.common import import_component
from mediagoblin.tools.routing import extract_url_arguments
+from mediagoblin.tools.text import convert_to_tag_list_of_dicts
import six
from six.moves.urllib.parse import urljoin
@@ -770,7 +771,6 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
"self": {
"href": public_id,
},
-
}
}
@@ -786,6 +786,12 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
if self.location:
context["location"] = self.get_location.serialize(request)
+ # Always show tags, even if empty list
+ if self.tags:
+ context["tags"] = [tag['name'] for tag in self.tags]
+ else:
+ context["tags"] = []
+
if show_comments:
comments = [
l.comment().serialize(request) for l in self.get_comments()]
@@ -833,6 +839,9 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
if "location" in data:
License.create(data["location"], self)
+ if "tags" in data:
+ self.tags = convert_to_tag_list_of_dicts(', '.join(data["tags"]))
+
return True
class FileKeynames(Base):