minor chages
This commit is contained in:
parent
959ee18f59
commit
e3f917a3ce
|
@ -14,13 +14,14 @@ class DeviceListView(View):
|
||||||
decorators = [login_required]
|
decorators = [login_required]
|
||||||
template_name = 'inventory/device_list.html'
|
template_name = 'inventory/device_list.html'
|
||||||
|
|
||||||
def dispatch_request(self, id=None):
|
def dispatch_request(self, lot_id=None):
|
||||||
# TODO @cayop adding filter
|
# TODO @cayop adding filter
|
||||||
|
# https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56
|
||||||
filter_types = ['Desktop', 'Laptop', 'Server']
|
filter_types = ['Desktop', 'Laptop', 'Server']
|
||||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||||
lot = None
|
lot = None
|
||||||
if id:
|
if lot_id:
|
||||||
lot = lots.filter(Lot.id == id).one()
|
lot = lots.filter(Lot.id == lot_id).one()
|
||||||
devices = [dev for dev in lot.devices if dev.type in filter_types]
|
devices = [dev for dev in lot.devices if dev.type in filter_types]
|
||||||
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
|
devices = sorted(devices, key=lambda x: x.updated, reverse=True)
|
||||||
else:
|
else:
|
||||||
|
@ -87,7 +88,7 @@ class LotCreateView(View):
|
||||||
form = LotForm()
|
form = LotForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
form.save()
|
form.save()
|
||||||
next_url = url_for('inventory.devices.lotdevicelist', id=form.id)
|
next_url = url_for('inventory.devices.lotdevicelist', lot_id=form.id)
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||||
|
@ -104,7 +105,7 @@ class LotUpdateView(View):
|
||||||
form = LotForm(id=id)
|
form = LotForm(id=id)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
form.save()
|
form.save()
|
||||||
next_url = url_for('inventory.devices.lotdevicelist', id=id)
|
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||||
|
@ -155,7 +156,7 @@ class CreateDeviceView(View):
|
||||||
|
|
||||||
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('/device/<string:id>/', view_func=DeviceDetailsView.as_view('device_details'))
|
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailsView.as_view('device_details'))
|
||||||
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
devices.add_url_rule('/lot/<string:lot_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=LotCreateView.as_view('lot_add'))
|
devices.add_url_rule('/lot/add/', view_func=LotCreateView.as_view('lot_add'))
|
||||||
|
|
|
@ -105,7 +105,7 @@
|
||||||
{% for lot in lots %}
|
{% for lot in lots %}
|
||||||
{% if lot.is_incominig %}
|
{% if lot.is_incominig %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
|
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
|
||||||
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
{% for lot in lots %}
|
{% for lot in lots %}
|
||||||
{% if lot.is_outgoing %}
|
{% if lot.is_outgoing %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
|
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
|
||||||
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
{% for lot in lots %}
|
{% for lot in lots %}
|
||||||
{% if lot.is_temporary %}
|
{% if lot.is_temporary %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ url_for('inventory.devices.lotdevicelist', id=lot.id) }}">
|
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
|
||||||
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Reference in a new issue