Add archiving items support
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending

This commit is contained in:
Madis Mägi 2024-10-22 20:51:55 +03:00
parent ede6c14e37
commit 3b7377581c
2 changed files with 23 additions and 0 deletions

View File

@ -259,6 +259,18 @@ def save_inventory_item(item_id=None, **_):
return render_template("inventory_edit.html", **locals())
return redirect("/m/inventory/%s/view" % item_id)
@page_inventory.route("/m/inventory/<item_id>/archive", methods=['POST'])
@login_required
def archive_inventory_item(item_id):
item = db.inventory.find_one({"_id": ObjectId(item_id)})
if not item:
return abort(404)
if not check_edit_permission(item_id):
return abort(403)
db.archive.insert_one(item);
db.inventory.delete_one({"_id": ObjectId(item_id)})
return redirect("/m/inventory")
@page_inventory.route("/m/inventory/add-slug/<slug>", methods=['GET'])
@login_required
def add_inventory_slug(slug):

View File

@ -206,6 +206,17 @@
</button>
</div>
</div>
<div class="row">
<div class="col s12">
<form action="/m/inventory/{{ item._id }}/archive" method="post" style="display: inline;">
<button {% if not can_edit %} disabled="" {% endif %} class="red lighten-1 waves-effect waves-light btn" type="submit">
<i class="material-icons left">archive</i>Archive
</button>
</form>
</div>
</div>
{% if can_audit %}
<div id="audit-modal" class="modal">
<div class="modal-content">