def migrate_news(self): old_items = sorted(self.zodb_root['modules']['news']._newsItems, key=attrgetter('_creationDate')) for old_item in old_items: n = NewsItem(title=_sanitize_title(old_item._title), content=convert_to_unicode(old_item._content), created_dt=old_item._creationDate) db.session.add(n) db.session.flush() self.print_success(n.title)
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)
def _process_args(self): RHManageNewsBase._process_args(self) self.item = NewsItem.get_one(request.view_args['news_id'])
def _process_args(self): self.item = NewsItem.get_or_404(request.view_args['news_id'])
def _checkParams(self, params): RHManageNewsBase._checkParams(self, params) self.item = NewsItem.get_one(request.view_args['news_id'])
def has_data(self): return NewsItem.has_rows()