Shorter path for partitions

`/albums/<album_uuid>/<partition_uuid>` -> `/partition/<partition_uuid>`
This commit is contained in:
augustin64 2023-10-13 14:36:04 +02:00
parent 972231e4b2
commit 340b6541ca
5 changed files with 3 additions and 30 deletions

View File

@ -92,32 +92,6 @@ def album(uuid):
return abort(404)
@bp.route("/<album_uuid>/<partition_uuid>")
def partition(album_uuid, partition_uuid):
"""
Returns a partition in a given album
"""
db = get_db()
partition = db.execute(
"""
SELECT * FROM partition
JOIN contient_partition ON partition_uuid = partition.uuid
JOIN album ON album.id = album_id
WHERE album.uuid = ?
AND partition.uuid = ?
""",
(album_uuid, partition_uuid),
).fetchone()
if partition is None:
return abort(404)
return send_file(
os.path.join("partitions", f"{partition_uuid}.pdf"),
download_name = f"{partition['name']}.pdf"
)
@bp.route("/create-album", methods=["POST"])
@login_required
def create_album():

View File

@ -13,7 +13,6 @@ from .utils import get_all_partitions, User, Partition
bp = Blueprint("partition", __name__, url_prefix="/partition")
@bp.route("/<uuid>")
@login_required
def partition(uuid):
db = get_db()
partition = db.execute(

View File

@ -66,7 +66,7 @@
<section id="partitions-grid">
{% for partition in partitions | reverse %}
<div>
<a href="/albums/{{ album.uuid }}/{{ partition['uuid'] }}">
<a href="/partition/{{ partition['uuid'] }}">
<div class="partition" id="partition-{{ partition['uuid'] }}">
<img class="partition-thumbnail" src="/static/thumbnails/{{ partition['uuid'] }}.jpg">
<div class="partition-description">

View File

@ -94,7 +94,7 @@
Aucun album
{% else %}
{% for album in groupe.get_albums() %}
<a href="/groupe/{{ groupe.uuid }}/{{ album["uuid"] }}">
<a href="/groupe/{{ groupe.uuid }}/{{ album['uuid'] }}">
<div class="groupe-album-cover">
{{ album["name"] }}
</div>

View File

@ -9,7 +9,7 @@
<form method="post">
<input type="submit" id="delete-partition" value="Supprimer">
</form>
<a class="button-href" href="/albums/{{ partition.uuid }}/edit">
<a class="button-href" href="/partition/{{ partition.uuid }}/edit">
<button id="cancel-deletion">Annuler</button>
</a>