remove lot
This commit is contained in:
parent
d17114a0b0
commit
d994cd2f10
|
@ -64,3 +64,8 @@ class LotForm(FlaskForm):
|
||||||
|
|
||||||
db.session.add(self.lot)
|
db.session.add(self.lot)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def remove(self):
|
||||||
|
if self.lot and not self.lot.devices:
|
||||||
|
self.lot.delete()
|
||||||
|
db.session.commit()
|
||||||
|
|
|
@ -80,9 +80,23 @@ class LotView(View):
|
||||||
return flask.render_template(self.template_name, form=form, title=self.title)
|
return flask.render_template(self.template_name, form=form, title=self.title)
|
||||||
|
|
||||||
|
|
||||||
|
class LotDeleteView(View):
|
||||||
|
methods = ['GET']
|
||||||
|
decorators = [login_required]
|
||||||
|
template_name = 'inventory/device_list.html'
|
||||||
|
|
||||||
|
def dispatch_request(self, id):
|
||||||
|
form = LotForm(id=id)
|
||||||
|
form.remove()
|
||||||
|
next_url = url_for('inventory.devices.devicelist')
|
||||||
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
||||||
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
||||||
devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add'))
|
devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add'))
|
||||||
devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del'))
|
devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del'))
|
||||||
devices.add_url_rule('/lot/add', view_func=LotView.as_view('lot_add'))
|
devices.add_url_rule('/lot/add/', view_func=LotView.as_view('lot_add'))
|
||||||
|
devices.add_url_rule('/lot/<string:id>/del/', view_func=LotDeleteView.as_view('lot_del'))
|
||||||
devices.add_url_rule('/lot/<string:id>/', view_func=LotView.as_view('lot_edit'))
|
devices.add_url_rule('/lot/<string:id>/', view_func=LotView.as_view('lot_edit'))
|
||||||
|
|
|
@ -33,11 +33,19 @@
|
||||||
<!-- Bordered Tabs -->
|
<!-- Bordered Tabs -->
|
||||||
|
|
||||||
<div class="btn-group dropdown ml-1">
|
<div class="btn-group dropdown ml-1">
|
||||||
|
{% if lot and lot.is_temporary and not lot.devices %}
|
||||||
|
<a href="{{ url_for('inventory.devices.lot_del', id=lot.id)}}" type="button" class="btn btn-primary">
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
Remove Lot
|
||||||
|
<span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
<button id="btnLots" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
<button id="btnLots" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
<i class="bi bi-folder2"></i>
|
<i class="bi bi-folder2"></i>
|
||||||
Lots
|
Lots
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
|
{% endif %}
|
||||||
<ul class="dropdown-menu" aria-labelledby="btnLots"">
|
<ul class="dropdown-menu" aria-labelledby="btnLots"">
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingLotModal">
|
<a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingLotModal">
|
||||||
|
|
Reference in New Issue