Exemple #1
0
 def delete_entry(self):
     entry_id = self.request.matchdict["id_"]
     entry = DBSession.query(Entry).filter(Entry.id == entry_id).one()
     DBSession.delete(entry)
     get_categories.invalidate()
     get_recent_posts.invalidate()
     return HTTPFound(location=self.request.route_url('home'))
Exemple #2
0
 def delete_category(self):
     category = DBSession.query(Category)\
         .options(subqueryload(Category.entries))\
         .filter(Category.name == self.request.matchdict["name_"])\
         .one()
     if category.entries:
         self.request.session.flash(
             'There are still entries in category %s, cannot delete!'
             % category.name)
     else:
         DBSession.delete(category)
     return HTTPFound(location=self.request.route_url('manage_categories'))