A bunch of small fixes

This commit is contained in:
augustin64 2023-10-11 15:57:06 +02:00
parent a65a80cd8b
commit 3f68ac0419
4 changed files with 20 additions and 20 deletions

View File

@ -27,7 +27,6 @@ def index():
for u in users:
u.albums = u.get_albums()
u.partitions = u.get_partitions()
db.close()
return render_template(
"admin/index.html",

View File

@ -171,10 +171,10 @@ def join_album(uuid):
user.join_album(uuid)
except LookupError:
flash("Cet album n'existe pas.")
return redirect(f"/albums/{uuid}")
return redirect(request.referrer)
flash("Album ajouté à la collection.")
return redirect(f"/albums/{uuid}")
return redirect(request.referrer)
@bp.route("/<uuid>/quit")
@ -185,7 +185,7 @@ def quit_album(uuid):
users = album.get_users()
if user.id not in [u["id"] for u in users]:
flash("Vous ne faites pas partie de cet album")
return redirect(f"/albums/{uuid}")
return redirect(request.referrer)
if len(users) == 1:
flash("Vous êtes seul dans cet album, le quitter entraînera sa suppression.")
@ -218,7 +218,7 @@ def delete_album(uuid):
if error is not None:
flash(error)
return redirect(f"/albums/{uuid}")
return redirect(request.referrer)
album.delete()
@ -236,7 +236,7 @@ def add_partition(album_uuid):
if (not user.is_participant(album.uuid)) and (user.access_level != 1):
flash("Vous ne participez pas à cet album.")
return redirect(f"/albums/{album.uuid}")
return redirect(request.referrer)
error = None
@ -264,7 +264,7 @@ def add_partition(album_uuid):
if error is not None:
flash(error)
return redirect(f"/albums/{album.uuid}")
return redirect(request.referrer)
if "author" in request.form:
author = request.form["author"]
@ -318,7 +318,7 @@ def add_partition(album_uuid):
pass
flash(f"Partition {request.form['name']} ajoutée")
return redirect(f"/albums/{album.uuid}")
return redirect(request.referrer)
@bp.route("/add-partition", methods=["POST"])

View File

@ -123,7 +123,6 @@ def register():
return redirect(url_for("auth.login"))
flash(error)
db.close()
return render_template("auth/register.html")

View File

@ -41,12 +41,13 @@ class Album():
self.users = None
def get_users(self):
def get_users(self, force_reload=False):
"""
Renvoie les utilisateurs liés à l'album
"""
if self.users is None or force_reload:
db = get_db()
return db.execute(
self.users = db.execute(
"""
SELECT * FROM user
JOIN contient_user ON user_id = user.id
@ -55,6 +56,7 @@ class Album():
""",
(self.uuid,)
).fetchall()
return self.users
def get_partitions(self):
"""