From: Michael Tremer Date: Wed, 8 May 2013 11:20:21 +0000 (+0200) Subject: planet: Fix saving new posts. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=00af5cf109fd2578f19ef13d6b74112690e038ab;p=ipfire.org.git planet: Fix saving new posts. --- diff --git a/webapp/backend/planet.py b/webapp/backend/planet.py index a1ea61e1..0be57123 100644 --- a/webapp/backend/planet.py +++ b/webapp/backend/planet.py @@ -204,10 +204,12 @@ class Planet(object): def save_entry(self, entry): slug = self._generate_slug(entry.title) - self.db.execute("INSERT INTO planet(author_id, title, slug, markdown, published) " + id = self.db.execute("INSERT INTO planet(author_id, title, slug, markdown, published) " "VALUES(%s, %s, %s, %s, UTC_TIMESTAMP())", entry.author.uid, entry.title, slug, entry.markdown) + return id + def search(self, what): # Split tags. tags = what.split() diff --git a/webapp/handlers_admin.py b/webapp/handlers_admin.py index c5ac7947..7310a43f 100644 --- a/webapp/handlers_admin.py +++ b/webapp/handlers_admin.py @@ -96,13 +96,14 @@ class AdminPlanetComposeHandler(AdminBaseHandler): entry.set("markdown", self.get_argument("markdown")) entry.set("author_id", self.current_user) - tags = self.get_argument("tags", "") - entry.tags = tags.split() - if id: self.planet.update_entry(entry) else: - self.planet.save_entry(entry) + id = self.planet.save_entry(entry) + entry.id = id + + tags = self.get_argument("tags", "") + entry.tags = tags.split() self.redirect("/planet")