diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 7e4d8ef8..59e66e07 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -64,9 +64,17 @@ class DeviceListMixin(GenericMixin): def get_context(self, lot_id=None, all_devices=False): super().get_context() + page = int(request.args.get('page', 1)) + per_page = int(request.args.get('per_page', PER_PAGE)) + filter = request.args.get('filter', "All+Computers") + # import pdb; pdb.set_trace() + lots = self.context['lots'] form_filter = FilterForm(lots, lot_id, all_devices=all_devices) - devices = form_filter.search() + devices = form_filter.search().paginate(page=page, per_page=per_page) + devices.first = per_page * devices.page - per_page + 1 + devices.last = len(devices.items) + devices.first - 1 + lot = None form_transfer = '' form_delivery = '' @@ -95,6 +103,7 @@ class DeviceListMixin(GenericMixin): 'tags': self.get_user_tags(), 'list_devices': self.get_selected_devices(form_new_action), 'all_devices': all_devices, + 'filter': filter, } ) @@ -161,17 +170,8 @@ class DeviceListView(DeviceListMixin): class AllDeviceListView(DeviceListMixin): - template_name = 'inventory/all_device_list.html' - def dispatch_request(self): self.get_context(all_devices=True) - # import pdb; pdb.set_trace() - page = int(request.args.get('page', 1)) - per_page = int(request.args.get('per_page', PER_PAGE)) - devices = self.context['devices'].paginate(page=page, per_page=per_page) - devices.first = per_page * devices.page - per_page + 1 - devices.last = len(devices.items) + devices.first - 1 - self.context['devices'] = devices return flask.render_template(self.template_name, **self.context) diff --git a/ereuse_devicehub/templates/inventory/all_device_list.html b/ereuse_devicehub/templates/inventory/all_device_list.html deleted file mode 100644 index 79ff81cd..00000000 --- a/ereuse_devicehub/templates/inventory/all_device_list.html +++ /dev/null @@ -1,671 +0,0 @@ -{% extends "ereuse_devicehub/base_site.html" %} -{% block main %} - -
- Displaying devices of type - {{ form_filter.filter.data or "Computer" }} -
- -Select | -Title | -DHID | -PHID | -Type | -Unique Identifiers | -Lifecycle Status | -Allocated Status | -Physical Status | -Updated in | -Registered in | -- |
---|---|---|---|---|---|---|---|---|---|---|---|
- - | -
-
- {% if dev.get_type_logo() %}
-
- {% endif %}
- {{ dev.verbose_name }}
-
- {% if dev.lots | length > 0 %}
- - {% for lot in dev.get_lots_for_template() %} - {{ lot }} - {% endfor %} -- {% endif %} - |
- - - {{ dev.devicehub_id }} - - | -- {{ dev.binding and dev.binding.phid or dev.placeholder and dev.placeholder.phid or '' }} - | -- {{ dev.is_abstract() }} - | -- {% for t in dev.tags | sort(attribute="id") %} - {{ t.id }} - {% if not loop.last %},{% endif %} - {% endfor %} - | -{% if dev.status %}{{ dev.status.type }}{% endif %} | -{% if dev.allocated_status %}{{ dev.allocated_status.type }}{% endif %} | -{% if dev.physical_status %}{{ dev.physical_status.type }}{% endif %} | -{{ dev.get_updated.strftime('%Y-%m-%d %H:%M:%S')}} | -{{ dev.created.strftime('%Y-%m-%d %H:%M:%S')}} | -- - - - | -
File | -Uploaded on | -
---|---|
- {% if doc.get_url() %} - {{ doc.file_name}} - {% else %} - {{ doc.file_name}} - {% endif %} - | -- {{ doc.created.strftime('%Y-%m-%d %H:%M')}} - | -
- {% if doc.get_url() %} - {{ doc.file_name}} - {% else %} - {{ doc.file_name}} - {% endif %} - | -- {{ doc.created.strftime('%Y-%m-%d %H:%M')}} - | -