Daddy PyLint is not happy

This commit is contained in:
Michał Gdula 2023-04-01 17:40:42 +00:00
parent ff1af6b888
commit 42375af3c3
4 changed files with 79 additions and 63 deletions

View file

@ -23,7 +23,7 @@ def index():
db.Posts.image_colours,
db.Posts.created_at,
db.Posts.id).order_by(db.Posts.id.desc()).all()
if request.args.get('coffee') == 'please':
abort(418)
@ -35,22 +35,28 @@ def image(image_id):
"""
Image view, shows the image and its metadata
"""
img = db_session.query(db.Posts).filter(db.Posts.id == image_id).first()
if not img:
# Get the image, if it doesn't exist, 404
image = db_session.query(db.Posts).filter(db.Posts.id == image_id).first()
if not image:
abort(404, 'Image not found :<')
img.author_username = db_session.query(db.Users.username)\
.filter(db.Users.id == img.author_id).first()[0]
# Get the image's author username
image.author_username = db_session.query(db.Users.username)\
.filter(db.Users.id == image.author_id).first()[0]
# Get the image's groups
groups = db_session.query(db.GroupJunction.group_id)\
.filter(db.GroupJunction.post_id == image_id).all()
img.groups = []
# For each group, get the group data and add it to the image item
image.groups = []
for group in groups:
group = db_session.query(db.Groups).filter(db.Groups.id == group[0]).first()
img.groups.append(group)
group = db_session.query(db.Groups.id, db.Groups.name)\
.filter(db.Groups.id == group[0])\
.first()
image.groups.append(group)
# Get the next and previous images
next_url = db_session.query(db.Posts.id)\
.filter(db.Posts.id > image_id)\
.order_by(db.Posts.id.asc())\
@ -60,12 +66,13 @@ def image(image_id):
.order_by(db.Posts.id.desc())\
.first()
# If there is a next or previous image, get the url
if next_url:
next_url = url_for('gallery.image', image_id=next_url[0])
if prev_url:
prev_url = url_for('gallery.image', image_id=prev_url[0])
return render_template('image.html', image=img, next_url=next_url, prev_url=prev_url)
return render_template('image.html', image=image, next_url=next_url, prev_url=prev_url)
@blueprint.route('/profile')