Add vacate button
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Madis Mägi 2023-11-26 00:44:10 +02:00
parent 17ea3dd87f
commit 94093a361e
2 changed files with 12 additions and 0 deletions

View File

@ -24,6 +24,7 @@ def view_inventory_view(item_id):
user = read_user() user = read_user()
template = "inventory_view.html" template = "inventory_view.html"
item = db.inventory.find_one({ "_id": ObjectId(item_id) }) item = db.inventory.find_one({ "_id": ObjectId(item_id) })
item_user = item.get("inventory", {}).get("user", {}).get("username", None)
if not user: if not user:
if not item["inventory"].get("public"): if not item["inventory"].get("public"):
return do_login() return do_login()
@ -31,6 +32,7 @@ def view_inventory_view(item_id):
else: else:
can_audit = "k-space:janitors" in user["groups"] can_audit = "k-space:janitors" in user["groups"]
can_edit = check_edit_permission(item_id) can_edit = check_edit_permission(item_id)
is_using = item_user and item_user == user["username"]
bucket=get_bucket() bucket=get_bucket()
photo_url = bucket.generate_presigned_url( photo_url = bucket.generate_presigned_url(
ClientMethod='get_object', ClientMethod='get_object',

View File

@ -150,6 +150,16 @@
</div> </div>
{% endif %} {% endif %}
{% if is_using %}
<div class="row">
<div class="col s12">
<form action="/m/inventory/{{ item._id }}/vacate" method="post" style="display: inline;">
<button class="waves-effect waves-light btn" type="submit">Vacate</button>
</form>
</div>
</div>
{% endif %}
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<a {% if not can_edit %} disabled="" {% endif %} href="/m/inventory/{{ item._id }}/edit" class="waves-effect waves-light btn"> <a {% if not can_edit %} disabled="" {% endif %} href="/m/inventory/{{ item._id }}/edit" class="waves-effect waves-light btn">