diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 63a5a336..1a7acc3d 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -4,6 +4,7 @@ from flask import Blueprint, url_for from flask_login import login_required, current_user from ereuse_devicehub.resources.lot.models import Lot +from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm @@ -95,6 +96,18 @@ class LotDeleteView(View): return flask.redirect(next_url) +class TagListView(View): + methods = ['GET'] + decorators = [login_required] + template_name = 'inventory/tag_list.html' + + def dispatch_request(self): + tags = Tag.query.filter( + Tag.owner_id == current_user.id) + context = {'tags': tags, + 'lots': []} + return flask.render_template(self.template_name, **context) + devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) devices.add_url_rule('/lot//device/', view_func=DeviceListView.as_view('lotdevicelist')) @@ -103,3 +116,4 @@ devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view( devices.add_url_rule('/lot/add/', view_func=LotView.as_view('lot_add')) devices.add_url_rule('/lot//del/', view_func=LotDeleteView.as_view('lot_del')) devices.add_url_rule('/lot//', view_func=LotView.as_view('lot_edit')) +devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist')) diff --git a/ereuse_devicehub/resources/tag/model.py b/ereuse_devicehub/resources/tag/model.py index 92c8d5d4..9c672f8c 100644 --- a/ereuse_devicehub/resources/tag/model.py +++ b/ereuse_devicehub/resources/tag/model.py @@ -136,6 +136,10 @@ class Tag(Thing): def code(self) -> str: return hashcode.encode(self.internal_id) + @property + def get_provider(self) -> str: + return self.provider.to_text() if self.provider else '' + def delete(self): """Deletes the tag. diff --git a/ereuse_devicehub/templates/inventory/tag_list.html b/ereuse_devicehub/templates/inventory/tag_list.html new file mode 100644 index 00000000..fdc96973 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/tag_list.html @@ -0,0 +1,87 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + + +
+

Inventory

+ +
+ +
+
+ +
+ +
+
+ + + + + + +
+ +
+ +
Computers
+ + + + + + + + + + + + {% for tag in tags %} + + + + + + + + {% endfor %} + +
Select allCodeTypeProviderDevice
{{ tag.code }}{% if tag.provider %}Unnamed tag {% else %}Named tag{% endif %}{{ tag.get_provider }}{% if tag.device %}{{ tag.device.type }} {{ tag.device.manufacturer }} {{ tag.device.model }}{% endif %}
+ +
+ +
+
+ +
+
+
+ + + + + + + +{% endblock main %}