Beispiel #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)
Beispiel #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)