diff --git a/ereuse_devicehub/forms.py b/ereuse_devicehub/forms.py index 4980b41e..ef383588 100644 --- a/ereuse_devicehub/forms.py +++ b/ereuse_devicehub/forms.py @@ -141,6 +141,9 @@ class SanitizationEntityForm(FlaskForm): if not is_valid: return False + if not self.logo.data: + return True + extensions = ["jpg", "jpeg", "png", "gif", "svg"] if self.logo.data.lower().split(".")[-1] not in extensions: txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index dff4e87e..ffb8d13c 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1565,6 +1565,9 @@ class CustomerDetailsForm(FlaskForm): if not is_valid: return is_valid + if not self.logo.data: + return True + extensions = ["jpg", "jpeg", "png", "gif", "svg"] if self.logo.data.lower().split(".")[-1] not in extensions: txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" 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 }} diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index 65cb4d3a..8f9a5e1d 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -145,7 +145,8 @@ class SanitizationEntityView(View): messages.error('Error modifying Sanitization data!') if form.errors: for k in form.errors.keys(): - txt = "{}: {}".format(k, form.errors[k]) + errors = ", ".join(form.errors[k]) + txt = "{}: {}".format(k, errors) messages.error(txt) return flask.redirect(flask.url_for('core.user-profile')) diff --git a/tests/test_basic.py b/tests/test_basic.py index e9927a0e..4b734079 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -68,6 +68,7 @@ def test_api_docs(client: Client): '/inventory/lot/{lot_id}/receivernote/', '/inventory/lot/{lot_id}/trade-document/add/', '/inventory/lot/{lot_id}/transfer/{type_id}/', + '/inventory/lot/{lot_id}/opentransfer/', '/inventory/lot/{lot_id}/transfer/', '/inventory/lot/transfer/{type_id}/', '/inventory/lot/{lot_id}/upload-snapshot/',