From 68269c4b211c6b6eb5b3fc00614e468b4e93f517 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 13 Jan 2022 16:08:55 +0100 Subject: [PATCH] device details --- ereuse_devicehub/inventory/views.py | 17 +- .../templates/inventory/device_details.html | 150 ++++++++++++++++++ .../templates/inventory/device_list.html | 6 +- 3 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 ereuse_devicehub/templates/inventory/device_details.html diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 21519123..9d259a80 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -21,7 +21,6 @@ class DeviceListView(View): lot = None if id: lot = lots.filter(Lot.id == id).one() - # import pdb; pdb.set_trace() devices = [dev for dev in lot.devices if dev.type in filter_types] devices = sorted(devices, key=lambda x: x.updated, reverse=True) else: @@ -36,6 +35,20 @@ class DeviceListView(View): return flask.render_template(self.template_name, **context) +class DeviceDetailsView(View): + decorators = [login_required] + template_name = 'inventory/device_details.html' + + def dispatch_request(self, id): + lots = Lot.query.filter(Lot.owner_id == current_user.id) + device = Device.query.filter( + Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one() + + context = {'device': device, + 'lots': lots} + return flask.render_template(self.template_name, **context) + + class LotDeviceAddView(View): methods = ['POST'] decorators = [login_required] @@ -109,8 +122,8 @@ class LotDeleteView(View): return flask.redirect(next_url) - devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) +devices.add_url_rule('/device//', view_func=DeviceDetailsView.as_view('device_details')) devices.add_url_rule('/lot//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/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del')) diff --git a/ereuse_devicehub/templates/inventory/device_details.html b/ereuse_devicehub/templates/inventory/device_details.html new file mode 100644 index 00000000..f6ebd522 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/device_details.html @@ -0,0 +1,150 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + + +
+

Inventory

+ +
+ +
+
+ +
+ +
+
+

{{ device.devicehub_id }}

+ + +
+ +
+
Type Details
+ +
+
Type
+
{{ device.type }}
+
+ +
+
Manufacturer
+
{{ device.manufacturer }}
+
+ +
+
Model
+
{{ device.model }}
+
+ +
+
Serial Number
+
{{ device.serial_number }}
+
+
+ +
+
Status Details
+
+
Physical States
+
{{ device.physical or '' }}
+
+
+
Trading States
+
{{ device.last_action_trading or ''}}
+
+
+
Usage States
+
{{ device.usage or '' }}
+
+
+ +
+
Rate Details
+
+
Rating
+
{{ device.rate or '' }}
+
+
+
Processor
+
{{ device.rate.processor or '' }}
+
+
+
RAM
+
{{ device.rate.ram or '' }}
+
+
+
Data storage
+
{{ device.rate.data_storage or '' }}
+
+
+ +
+
Traceability log Details
+
+ {% for action in device.actions %} +
+ {{ action.type }} {{ action.severity }} + {{ action.created.strftime('%H:%M %d-%m-%Y') }} +
+ {% endfor %} +
+
+ +
+
Components Details
+
+ {% for component in device.components|sort(attribute='type') %} +
+
+
{{ component.type }}
+ {{ component.created.strftime('%H:%M %d-%m-%Y') }} +
+

+ {{ component.manufacturer }}
+ {{ component.model }}
+

+ + {% if component.type in ['RamModule', 'HardDrive', 'SolidStateDrive'] %} + {{ component.size }}MB + {% endif %} + +
+ {% endfor %} +
+
+ +
+
+
+
+
+{% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 79d01a40..38ecfe9d 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -6,7 +6,7 @@

Inventory