def checknewscomments(news): orm.sql_debug(False) if not news: with orm.db_session: first_newsitem = orm.select(orm.min(x.id) for x in NewsItem).first() last_newsitem = orm.select(orm.max(x.id) for x in NewsItem).first() newsitem_id = first_newsitem else: i = 0 while True: with orm.db_session: if not news: newsitem = NewsItem.select(lambda x: x.id >= newsitem_id and x.id <= last_newsitem).first() if not newsitem: break else: if i >= len(news): break if news[i].isdigit(): newsitem = NewsItem.get(id=int(news[i])) else: newsitem = NewsItem.get(name=news[i]) i += 1 if not newsitem: print('News item {} not found'.format(news[i - 1])) continue print('News item {} ({})'.format(newsitem.id, newsitem.name)) comments_list = newsitem.bl.select_comments().order_by('c.date, c.id') check_comments_for(newsitem, comments_list) newsitem_id = newsitem.id + 1
def index(page): objects = NewsItem.select().order_by(NewsItem.id.desc()) return paginate_view( 'news/index.html', objects, count=objects.count(), page_title=gettext('News'), objlistname='news', per_page=100, )
def index(page): objects = NewsItem.select().order_by(NewsItem.id.desc()) return paginate_view( 'admin/news/index.html', objects, count=objects.count(), page_title=gettext('News'), objlistname='news', per_page=100, )
def checknewscomments(news): orm.sql_debug(False) if not news: with orm.db_session: first_newsitem = orm.select(orm.min(x.id) for x in NewsItem).first() last_newsitem = orm.select(orm.max(x.id) for x in NewsItem).first() newsitem_id = first_newsitem else: i = 0 while True: with orm.db_session: if not news: newsitem = NewsItem.select(lambda x: x.id >= newsitem_id and x. id <= last_newsitem).first() if not newsitem: break else: if i >= len(news): break if news[i].isdigit(): newsitem = NewsItem.get(id=int(news[i])) else: newsitem = NewsItem.get(name=news[i]) i += 1 if not newsitem: print('News item {} not found'.format(news[i - 1])) continue print('News item {} ({})'.format(newsitem.id, newsitem.name)) comments_list = newsitem.bl.select_comments().order_by( 'c.date, c.id') check_comments_for(newsitem, comments_list) newsitem_id = newsitem.id + 1
def news(params): news_list = list(NewsItem.select().order_by(NewsItem.id.desc())[:3]) return render_template('sidebar/news.html', news=news_list)
def news(params): news_list = list(NewsItem.select().order_by(NewsItem.id.desc())[:3]) return render_template('sidebar/news.html', news=news_list)