Merge pull request #434 from eReuse/bugfix/4281

Bugfix/4281
This commit is contained in:
cayop 2023-03-13 18:25:47 +01:00 committed by GitHub
commit 56c970e810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 8 deletions

View file

@ -141,6 +141,9 @@ class SanitizationEntityForm(FlaskForm):
if not is_valid: if not is_valid:
return False return False
if not self.logo.data:
return True
extensions = ["jpg", "jpeg", "png", "gif", "svg"] extensions = ["jpg", "jpeg", "png", "gif", "svg"]
if self.logo.data.lower().split(".")[-1] not in extensions: if self.logo.data.lower().split(".")[-1] not in extensions:
txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions"

View file

@ -1565,6 +1565,9 @@ class CustomerDetailsForm(FlaskForm):
if not is_valid: if not is_valid:
return is_valid return is_valid
if not self.logo.data:
return True
extensions = ["jpg", "jpeg", "png", "gif", "svg"] extensions = ["jpg", "jpeg", "png", "gif", "svg"]
if self.logo.data.lower().split(".")[-1] not in extensions: if self.logo.data.lower().split(".")[-1] not in extensions:
txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions" txt = "Error in Url field - accepted only .PNG, .JPG and .GIF. extensions"

View file

@ -841,6 +841,21 @@ class NewTransferView(GenericMixin):
return flask.render_template(self.template_name, **self.context) 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): class EditTransferView(GenericMixin):
methods = ['POST'] methods = ['POST']
form_class = EditTransferForm form_class = EditTransferForm
@ -1601,3 +1616,7 @@ devices.add_url_rule(
'/device/erasure/<int:orphans>/', '/device/erasure/<int:orphans>/',
view_func=ErasureListView.as_view('device_erasure_list_orphans'), view_func=ErasureListView.as_view('device_erasure_list_orphans'),
) )
devices.add_url_rule(
'/lot/<string:lot_id>/opentransfer/',
view_func=OpenTransferView.as_view('open_transfer'),
)

View file

@ -565,6 +565,15 @@
</table> </table>
</div> </div>
<div id="edit-transfer" class="tab-pane fade edit-transfer"> <div id="edit-transfer" class="tab-pane fade edit-transfer">
{% if form_transfer.date.data %}
<div class="btn-group dropdown ml-1 mt-1" uib-dropdown="">
<a href="{{ url_for('inventory.open_transfer', lot_id=lot.id)}}" class="btn btn-primary">
<i class="bi bi-plus"></i>
Reopen a transfer
<span class="caret"></span>
</a>
</div>
{% endif %}
<h5 class="card-title">Transfer</h5> <h5 class="card-title">Transfer</h5>
<form method="post" action="{{ url_for('inventory.edit_transfer', lot_id=lot.id) }}" class="row g-3 needs-validation" novalidate> <form method="post" action="{{ url_for('inventory.edit_transfer', lot_id=lot.id) }}" class="row g-3 needs-validation" novalidate>
{{ form_transfer.csrf_token }} {{ form_transfer.csrf_token }}

View file

@ -145,7 +145,8 @@ class SanitizationEntityView(View):
messages.error('Error modifying Sanitization data!') messages.error('Error modifying Sanitization data!')
if form.errors: if form.errors:
for k in form.errors.keys(): for k in form.errors.keys():
txt = "{}: {}".format(k, form.errors[k]) errors = ", ".join(form.errors[k])
txt = "{}: {}".format(k, errors)
messages.error(txt) messages.error(txt)
return flask.redirect(flask.url_for('core.user-profile')) return flask.redirect(flask.url_for('core.user-profile'))

View file

@ -68,6 +68,7 @@ def test_api_docs(client: Client):
'/inventory/lot/{lot_id}/receivernote/', '/inventory/lot/{lot_id}/receivernote/',
'/inventory/lot/{lot_id}/trade-document/add/', '/inventory/lot/{lot_id}/trade-document/add/',
'/inventory/lot/{lot_id}/transfer/{type_id}/', '/inventory/lot/{lot_id}/transfer/{type_id}/',
'/inventory/lot/{lot_id}/opentransfer/',
'/inventory/lot/{lot_id}/transfer/', '/inventory/lot/{lot_id}/transfer/',
'/inventory/lot/transfer/{type_id}/', '/inventory/lot/transfer/{type_id}/',
'/inventory/lot/{lot_id}/upload-snapshot/', '/inventory/lot/{lot_id}/upload-snapshot/',