Correct code I did done yesterday

This commit is contained in:
Michał Gdula 2023-04-07 09:18:03 +00:00
parent d1b3afdb22
commit 8357241487
10 changed files with 62 additions and 18 deletions

View file

@ -3,7 +3,7 @@ Onlylegs - Image View
"""
from math import ceil
from flask import Blueprint, abort, render_template, url_for
from flask import Blueprint, abort, render_template, url_for, current_app
from sqlalchemy.orm import sessionmaker
from gallery import db
@ -63,11 +63,11 @@ def image(image_id):
total_images = (db_session.query(db.Posts.id)
.order_by(db.Posts.id.desc())
.all())
limit = 100
limit = current_app.config['UPLOAD_CONF']['max-load']
# If the number of items is less than the limit, no point of calculating the page
if len(total_images) <= limit:
return_page = 1
return_page = None
else:
# How many pages should there be
for i in range(ceil(len(total_images) / limit)):