From 3066ac8d8789df8c540f900eef9234b314085103 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 16 Apr 2014 17:54:22 +0200 Subject: [PATCH] planet: Remove tags. --- templates/admin-planet-compose.html | 9 ------- templates/planet/posting.html | 6 ----- webapp/backend/planet.py | 37 ++++------------------------- webapp/handlers_admin.py | 4 +--- 4 files changed, 5 insertions(+), 51 deletions(-) diff --git a/templates/admin-planet-compose.html b/templates/admin-planet-compose.html index 49a30e4..a549954 100644 --- a/templates/admin-planet-compose.html +++ b/templates/admin-planet-compose.html @@ -29,15 +29,6 @@
-
- -
- -
-
-
diff --git a/templates/planet/posting.html b/templates/planet/posting.html index 9c622b0..aff4f1a 100644 --- a/templates/planet/posting.html +++ b/templates/planet/posting.html @@ -19,12 +19,6 @@ {% raw entry.text %}

- {% if entry.tags %} - {{ _("Tags") }}: - {% for tag in entry.tags %} - {{ tag }} - {% end %} • - {% end %} {{ _("Posted by") }} {{ entry.author.cn }} {{ _("on") }} {{ locale.format_date(entry.published, shorter=True) }}

diff --git a/webapp/backend/planet.py b/webapp/backend/planet.py index 47036a1..e063d3b 100644 --- a/webapp/backend/planet.py +++ b/webapp/backend/planet.py @@ -115,31 +115,6 @@ class PlanetEntry(Object): def is_published(self): return self.status == "published" - # Tags - - def get_tags(self): - if not hasattr(self, "__tags"): - res = self.db.query("SELECT tag FROM planet_tags \ - WHERE post_id = %s ORDER BY tag", self.id) - self.__tags = [] - for row in res: - self.__tags.append(row.tag) - - return self.__tags - - def set_tags(self, tags): - # Delete all existing tags. - self.db.execute("DELETE FROM planet_tags WHERE post_id = %s", self.id) - - self.db.executemany("INSERT INTO planet_tags(post_id, tag) VALUES(%s, %s)", - ((self.id, tag) for tag in tags)) - - # Update cache. - self.__tags = tags - self.__tags.sort() - - tags = property(get_tags, set_tags) - class Planet(Object): def get_authors(self): @@ -237,7 +212,7 @@ class Planet(Object): return slug - def create(self, title, markdown, author, status="published", tags=None, published=None): + def create(self, title, markdown, author, status="published", published=None): slug = self._generate_slug(title) markup = self.render(markdown) @@ -245,15 +220,11 @@ class Planet(Object): published = datetime.datetime.utcnow() id = self.db.execute("INSERT INTO planet(author_id, slug, title, status, \ - markdown, markup, published) VALUES(%s, %s, %s, %s, %s, %s, %s)", + markdown, markup, published) VALUES(%s, %s, %s, %s, %s, %s, %s) RETURNING id", author.uid, slug, title, status, markdown, markup, published) - entry = self.get_entry_by_id(id) - - if tags: - entry.tags = tags - - return entry + if id: + return self.get_entry_by_id(id) def update_entry(self, entry): self.db.execute("UPDATE planet SET title = %s, markdown = %s WHERE id = %s", diff --git a/webapp/handlers_admin.py b/webapp/handlers_admin.py index e7c7217..600a627 100644 --- a/webapp/handlers_admin.py +++ b/webapp/handlers_admin.py @@ -77,7 +77,6 @@ class AdminPlanetComposeHandler(AdminBaseHandler): def post(self): title = self.get_argument("title") markdown = self.get_argument("markdown") - tags = self.get_argument("tags", "") status = self.get_argument("status", "draft") assert status in ("draft", "published") @@ -85,7 +84,7 @@ class AdminPlanetComposeHandler(AdminBaseHandler): author = self.accounts.find(self.current_user) entry = self.planet.create(title=title, markdown=markdown, - author=author, status=status, tags=tags.split()) + author=author, status=status) self.redirect("/planet") @@ -99,7 +98,6 @@ class AdminPlanetEditHandler(AdminPlanetComposeHandler): entry.title = self.get_argument("title") entry.markdown = self.get_argument("markdown") - entry.tags = self.get_argument("tags", "").split() entry.status = self.get_argument("status", "draft") -- 2.39.2