always show the button to delete a lot and show an error message if you try to delete a lot with devices
This commit is contained in:
parent
6b3ccee58f
commit
496763473e
|
@ -211,6 +211,13 @@ class LotDeleteView(View):
|
||||||
|
|
||||||
def dispatch_request(self, id):
|
def dispatch_request(self, id):
|
||||||
form = LotForm(id=id)
|
form = LotForm(id=id)
|
||||||
|
if form.instance.devices:
|
||||||
|
msg = ("Sorry, the lot cannot be deleted because it still "
|
||||||
|
"has associated devices. Only empty lots can be deleted")
|
||||||
|
messages.error(msg)
|
||||||
|
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
|
||||||
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
form.remove()
|
form.remove()
|
||||||
next_url = url_for('inventory.devices.devicelist')
|
next_url = url_for('inventory.devices.devicelist')
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<h3><a href="{{ url_for('inventory.devices.lot_edit', id=lot.id) }}">{{ lot.name }}</a></h3>
|
<h3><a href="{{ url_for('inventory.devices.lot_edit', id=lot.id) }}">{{ lot.name }}</a></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{% if lot and lot.is_temporary and not lot.devices %}
|
{% if lot and lot.is_temporary %}
|
||||||
<a href="javascript:void()" data-bs-toggle="modal" data-bs-target="#btnRemoveLots">
|
<a href="javascript:void()" data-bs-toggle="modal" data-bs-target="#btnRemoveLots">
|
||||||
<i class="bi bi-trash"></i>
|
<i class="bi bi-trash"></i>
|
||||||
Remove Lot
|
Remove Lot
|
||||||
|
|
Reference in a new issue