mediagoblin-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GMG-Devel] [PATCH] Added tags in API (view them and edit them)


From: Romain Porte
Subject: [GMG-Devel] [PATCH] Added tags in API (view them and edit them)
Date: Sat, 11 Nov 2017 16:02:27 +0100

---
 mediagoblin/db/models.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index f4644b9f..d993ba88 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,9 @@ class MediaEntry(Base, MediaEntryMixin, CommentingMixin):
         if self.location:
             context["location"] = self.get_location.serialize(request)
 
+        if self.tags:
+            context["tags"] = [tag['name'] for tag in self.tags]
+
         if show_comments:
             comments = [
                 l.comment().serialize(request) for l in self.get_comments()]
@@ -833,6 +836,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):
-- 
2.15.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]