mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Update database
Correctly link user to their posts and groups Change the table names to Group, Post and User Remove unused Bans and Logs table, possibly will return later
This commit is contained in:
parent
9a21064dd5
commit
d36699bd1f
12 changed files with 185 additions and 270 deletions
|
@ -6,7 +6,7 @@ from math import ceil
|
|||
from flask import Blueprint, render_template, request, current_app
|
||||
from werkzeug.exceptions import abort
|
||||
|
||||
from gallery.models import Posts
|
||||
from gallery.models import Post
|
||||
|
||||
|
||||
blueprint = Blueprint("gallery", __name__)
|
||||
|
@ -27,7 +27,7 @@ def index():
|
|||
|
||||
# get the total number of images in the database
|
||||
# calculate the total number of pages, and make sure the page number is valid
|
||||
total_images = Posts.query.with_entities(Posts.id).count()
|
||||
total_images = Post.query.with_entities(Post.id).count()
|
||||
pages = ceil(max(total_images, limit) / limit)
|
||||
if page > pages:
|
||||
abort(
|
||||
|
@ -38,10 +38,9 @@ def index():
|
|||
|
||||
# get the images for the current page
|
||||
images = (
|
||||
Posts.query.with_entities(
|
||||
Posts.filename, Posts.alt, Posts.colours, Posts.created_at, Posts.id
|
||||
)
|
||||
.order_by(Posts.id.desc())
|
||||
Post.query
|
||||
.with_entities( Post.filename, Post.alt, Post.colours, Post.created_at, Post.id)
|
||||
.order_by(Post.id.desc())
|
||||
.offset((page - 1) * limit)
|
||||
.limit(limit)
|
||||
.all()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue