def admin_only(): if 'username' not in session: return redirect('/login') news = NewsModel(news_db.get_connection()).get_all() news.sort(key=lambda x: x[3]) return render_template('index.html', username=session['username'], news=news)
def admin_only(): if 'username' not in session: return redirect('/login') news = NewsModel(news_db.get_connection()).get_all() news.sort(key=lambda x: x[3]) user_model = UsersModel(users_db.get_connection()) usernames = {} for item in news: data = user_model.get(item[4]) if item[4] not in usernames: usernames.update( {item[4]: [str(data[2] + ' ' + data[3]), data[1]]}) return render_template('index.html', username=session['username'], news=news, users=usernames)
def sort_by(sort): if 'username' not in session: return redirect('/login') nm = NewsModel(db.get_connection()) news = nm.sort(sort, user_id=session['user_id']) return render_template('index.html', username=session['username'], news=news)
def index(): if 'username' not in session: return redirect('/ban') news = NewsModel(news_db.get_connection()).get_all(session['user_id']) news.sort(key=lambda x: x[3]) news.reverse() user_model = UsersModel(users_db.get_connection()) usernames = {} for item in news: data = user_model.get(item[4]) if item[4] not in usernames: usernames.update( {item[4]: [str(data[2] + ' ' + data[3]), data[1]]}) return render_template('index.html', title='a', username=session['username'], cur_user_id=session['user_id'], news=news, users=usernames)