mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-01-23 17:26:26 +01:00
A bunch of small fixes
This commit is contained in:
parent
a65a80cd8b
commit
3f68ac0419
@ -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",
|
||||
|
@ -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"])
|
||||
|
@ -123,7 +123,6 @@ def register():
|
||||
return redirect(url_for("auth.login"))
|
||||
|
||||
flash(error)
|
||||
db.close()
|
||||
|
||||
return render_template("auth/register.html")
|
||||
|
||||
|
@ -41,20 +41,22 @@ class Album():
|
||||
self.users = None
|
||||
|
||||
|
||||
def get_users(self):
|
||||
def get_users(self, force_reload=False):
|
||||
"""
|
||||
Renvoie les utilisateurs liés à l'album
|
||||
"""
|
||||
db = get_db()
|
||||
return db.execute(
|
||||
"""
|
||||
SELECT * FROM user
|
||||
JOIN contient_user ON user_id = user.id
|
||||
JOIN album ON album.id = album_id
|
||||
WHERE album.uuid = ?
|
||||
""",
|
||||
(self.uuid,)
|
||||
).fetchall()
|
||||
if self.users is None or force_reload:
|
||||
db = get_db()
|
||||
self.users = db.execute(
|
||||
"""
|
||||
SELECT * FROM user
|
||||
JOIN contient_user ON user_id = user.id
|
||||
JOIN album ON album.id = album_id
|
||||
WHERE album.uuid = ?
|
||||
""",
|
||||
(self.uuid,)
|
||||
).fetchall()
|
||||
return self.users
|
||||
|
||||
def get_partitions(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user