@ -1,5 +1,6 @@
import json
import click
from math import ceil
from datetime import datetime , timedelta
from random import choice
from os import makedirs , path , remove
@ -30,7 +31,7 @@ app.register_blueprint(api.bp)
@app.route ( " / " )
def index ( ) :
itp = 20
itp = 15
page = request . args . get ( " page " , 1 )
submitter = request . args . get ( " submitter " , None )
try :
@ -42,9 +43,15 @@ def index():
posts = Post . select ( ) . where ( Post . approved == True ) . order_by ( Post . timestamp . desc ( ) )
if submitter :
posts = posts . where ( Post . submitter == submitter )
posts = posts . paginate ( page , itp )
total_pages = Post . select ( ) . count ( ) / itp
return render_template ( " index.html " , posts = posts , page = page , total_pages = total_pages )
paginated_posts = posts . paginate ( page , itp )
total_pages = ceil ( posts . count ( ) / itp )
return render_template (
" index.html " ,
posts = paginated_posts ,
page = page ,
total_pages = total_pages
)
@app.route ( " /mod " )
@moderator_required