From 21d251e6c03008b878af45dc549d445ba86b576a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 13 Mar 2023 17:52:00 +0100 Subject: [PATCH] add reopen transfer --- ereuse_devicehub/inventory/views.py | 19 +++++++++++++++ .../templates/inventory/device_list.html | 23 +++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index b03cd345..2526a850 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -841,6 +841,21 @@ class NewTransferView(GenericMixin): return flask.render_template(self.template_name, **self.context) +class OpenTransferView(GenericMixin): + methods = ['GET'] + + def dispatch_request(self, lot_id=None): + lot = Lot.query.filter_by(id=lot_id).one() + next_url = url_for('inventory.lotdevicelist', lot_id=str(lot_id)) + + if hasattr(lot, 'transfer'): + lot.transfer.date = None + db.session.commit() + messages.success('Transfer was reopen successfully!') + + return flask.redirect(next_url) + + class EditTransferView(GenericMixin): methods = ['POST'] form_class = EditTransferForm @@ -1601,3 +1616,7 @@ devices.add_url_rule( '/device/erasure//', view_func=ErasureListView.as_view('device_erasure_list_orphans'), ) +devices.add_url_rule( + '/lot//opentransfer/', + view_func=OpenTransferView.as_view('open_transfer'), +) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index f89c93f6..7f5ac904 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -516,13 +516,13 @@ {% if lot and not lot.is_temporary %}
- +
Documents
@@ -565,6 +565,15 @@
+ {% if form_transfer.date.data %} + + {% endif %}
Transfer
{{ form_transfer.csrf_token }}