mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Correct code I did done yesterday
This commit is contained in:
parent
d1b3afdb22
commit
8357241487
10 changed files with 62 additions and 18 deletions
|
@ -136,5 +136,4 @@ def group_post(group_id, image_id):
|
|||
if prev_url:
|
||||
prev_url = url_for('group.group_post', group_id=group_id, image_id=prev_url[0])
|
||||
|
||||
return render_template('image.html', image=image, next_url=next_url,
|
||||
prev_url=prev_url, return_page=0)
|
||||
return render_template('image.html', image=image, next_url=next_url, prev_url=prev_url)
|
||||
|
|
|
@ -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)):
|
||||
|
|
|
@ -3,7 +3,7 @@ Onlylegs Gallery - Index view
|
|||
"""
|
||||
from math import ceil
|
||||
|
||||
from flask import Blueprint, render_template, request
|
||||
from flask import Blueprint, render_template, request, current_app
|
||||
from werkzeug.exceptions import abort
|
||||
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
@ -26,7 +26,7 @@ def index():
|
|||
|
||||
# pagination, defaults to page 1 if no page is specified
|
||||
page = request.args.get('page', default=1, type=int)
|
||||
limit = 100
|
||||
limit = current_app.config['UPLOAD_CONF']['max-load']
|
||||
|
||||
# get the total number of images in the database
|
||||
# calculate the total number of pages, and make sure the page number is valid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue