示例#1
0
 def _process(self):
     form = NewsForm(obj=self.item)
     if form.validate_on_submit():
         old_title = self.item.title
         form.populate_obj(self.item)
         db.session.flush()
         get_recent_news.clear_cached()
         logger.info('News %r modified by %s', self.item, session.user)
         flash(_("News '{title}' has been updated").format(title=old_title), 'success')
         return jsonify_data(flash=False)
     return jsonify_form(form)
示例#2
0
 def _process(self):
     form = NewsForm()
     if form.validate_on_submit():
         item = NewsItem()
         form.populate_obj(item)
         db.session.add(item)
         db.session.flush()
         get_recent_news.clear_cached()
         logger.info('News %r created by %s', item, session.user)
         flash(_("News '{title}' has been posted").format(title=item.title), 'success')
         return jsonify_data(flash=False)
     return jsonify_form(form)
示例#3
0
 def _process(self):
     db.session.delete(self.item)
     get_recent_news.clear_cached()
     flash(_("News '{title}' has been deleted").format(title=self.item.title), 'success')
     logger.info('News %r deleted by %r', self.item, session.user)
     return redirect(url_for('news.manage'))