From 54a28856f0a57db8195529e86a13c86debe1047f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:35:05 +0000 Subject: [PATCH 01/31] Bump sqlalchemy from 1.2.17 to 1.3.0 Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.2.17 to 1.3.0. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/master/CHANGES) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f4349c18..92e3c0f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ python-stdnum==1.9 PyYAML==3.13 requests[security]==2.27.1 requests-mock==1.5.2 -SQLAlchemy==1.2.17 +SQLAlchemy==1.3.0 SQLAlchemy-Utils==0.33.11 teal==0.2.0a38 webargs==5.5.3 From 5dbbe775d801b708e730219ba10815ca637f301a Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Mon, 7 Feb 2022 18:56:34 +0100 Subject: [PATCH 02/31] Bump sqlalchemy from 1.2.17 to 1.3.24 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 92e3c0f5..96b2a227 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ python-stdnum==1.9 PyYAML==3.13 requests[security]==2.27.1 requests-mock==1.5.2 -SQLAlchemy==1.3.0 +SQLAlchemy==1.3.24 SQLAlchemy-Utils==0.33.11 teal==0.2.0a38 webargs==5.5.3 From fbedbc8f7fda62572c02a47bc079537442f9c2a2 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 22 Feb 2022 12:22:23 +0100 Subject: [PATCH 03/31] Drop Additional keyword arguments [Deprecated since version 0.9](https://docs.sqlalchemy.org/en/12/core/type_basics.html#sqlalchemy.types.Float.params.**kwargs) --- ereuse_devicehub/resources/action/models.py | 2 +- ereuse_devicehub/resources/tradedocument/models.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index a213ced5..6fc039aa 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -1748,7 +1748,7 @@ class MoveOnDocument(JoinedTableMixin, ActionWithMultipleTradeDocuments): """Action than certify one movement of some indescriptible material of one container to an other.""" - weight = db.Column(db.Float(nullable=True)) + weight = db.Column(db.Float()) weight.comment = """Weight than go to recycling""" container_from_id = db.Column( db.BigInteger, diff --git a/ereuse_devicehub/resources/tradedocument/models.py b/ereuse_devicehub/resources/tradedocument/models.py index 177b2bd3..59d8a8c4 100644 --- a/ereuse_devicehub/resources/tradedocument/models.py +++ b/ereuse_devicehub/resources/tradedocument/models.py @@ -72,7 +72,7 @@ class TradeDocument(Thing): file_hash.comment = """This is the hash of the file produced from frontend.""" url = db.Column(URL()) url.comment = """This is the url where resides the document.""" - weight = db.Column(db.Float(nullable=True)) + weight = db.Column(db.Float()) weight.comment = """This is the weight of one container than this document express.""" __table_args__ = ( @@ -150,10 +150,10 @@ class TradeDocument(Thing): with suppress(StopIteration, ValueError): actions = copy.copy(self.actions) actions.sort(key=lambda x: x.created) - t_trades = ['Trade', - 'Confirm', - 'ConfirmRevokeDocument', - 'RevokeDocument', + t_trades = ['Trade', + 'Confirm', + 'ConfirmRevokeDocument', + 'RevokeDocument', 'ConfirmDocument'] return next(e for e in reversed(actions) if e.t in t_trades) From c51f1aa2e3179ae4437248863cab464ef8a44519 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 22 Feb 2022 12:31:56 +0100 Subject: [PATCH 04/31] Pin itsdangerous version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix ImportError: cannot import name ‘json’ from itsdangerous --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9a8b67a3..303ffeb3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ Flask-Cors==3.0.10 Flask-SQLAlchemy==2.3.2 hashids==1.2.0 inflection==0.3.1 +itsdangerous==2.0.1 marshmallow==3.0.0b11 marshmallow-enum==1.4.1 passlib==1.7.1 From ef4a6a3a92f58c40e0b60b841a57841b7cddfc61 Mon Sep 17 00:00:00 2001 From: Santiago L Date: Wed, 2 Mar 2022 17:46:29 +0100 Subject: [PATCH 05/31] Update CONTRIBUTING.md Remove comment --- CONTRIBUTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16e3dfea..c34d93c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,3 @@ -; SHARED on https://pad.cas.cat/usody-devicehub-contributing - # Contributing to devicehub ## Writing code From d25c9faf253c0aa4b20074e7d6538a311260c449 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Mar 2022 10:43:34 +0100 Subject: [PATCH 06/31] fix change #2825, tags only for Computers --- ereuse_devicehub/resources/device/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index a97c7392..7c230f57 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -1206,8 +1206,9 @@ def create_code_tag(mapper, connection, device): this tag is the same of devicehub_id. """ from ereuse_devicehub.resources.tag.model import Tag - tag = Tag(device_id=device.id, id=device.devicehub_id) - db.session.add(tag) + if isinstance(device, Computer): + tag = Tag(device_id=device.id, id=device.devicehub_id) + db.session.add(tag) event.listen(Device, 'after_insert', create_code_tag, propagate=True) From 95a8b13a6b3f012ad9b64dc87f25f36a94ee3bc4 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 4 Mar 2022 13:00:51 +0100 Subject: [PATCH 07/31] form select type of device in the list of device. Step 1 --- ereuse_devicehub/inventory/views.py | 8 +++++++- ereuse_devicehub/templates/inventory/device_list.html | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 62cd97cb..2329fa22 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -42,7 +42,13 @@ class DeviceListMix(View): def get_context(self, lot_id): # TODO @cayop adding filter # https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56 - filter_types = ['Desktop', 'Laptop', 'Server'] + import pdb; pdb.set_trace() + type_device = { + None: ['Desktop', 'Laptop', 'Server'], + 'Computer': ['Computer'], + 'Monitor': ['Monitor'], + } + filter_types = type_device[request.get('filter')] lots = Lot.query.outerjoin(Trade) \ .filter(or_(Trade.user_from == g.user, Trade.user_to == g.user, diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 63395f5a..4170318d 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -279,10 +279,17 @@
Computers
+
+ + +
- + From 598b91e22b78f40e0589462145cae9c272a67547 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Mar 2022 13:07:26 +0100 Subject: [PATCH 08/31] filter search in lists --- ereuse_devicehub/inventory/forms.py | 20 +++++++++++++++++++ ereuse_devicehub/inventory/views.py | 15 +++++--------- .../templates/inventory/device_list.html | 16 ++++++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 7702be79..945270b4 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -35,6 +35,26 @@ from ereuse_devicehub.resources.action.models import Trade from sqlalchemy import or_ +DEVICES = [ + ("Computer", "Computer"), + ("Monitor", "Monitor"), +] + + +class FilterForm(FlaskForm): + filter = SelectField('', choices=DEVICES, default="Comupter", + render_kw={'class': "form-select"}) + + def search(self): + + type_device = { + None: ['Desktop', 'Laptop', 'Server'], + 'Computer': ['Computer'], + 'Monitor': ['Monitor'], + } + return type_device.get(request.args.get('filter')) or type_device[None] + + class LotDeviceForm(FlaskForm): lot = StringField('Lot', [validators.UUID()]) devices = StringField('Devices', [validators.length(min=1)]) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 2329fa22..9c4d2e10 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -13,6 +13,7 @@ from ereuse_devicehub import messages from ereuse_devicehub.inventory.forms import ( AllocateForm, DataWipeForm, + FilterForm, LotDeviceForm, LotForm, NewActionForm, @@ -40,15 +41,9 @@ class DeviceListMix(View): template_name = 'inventory/device_list.html' def get_context(self, lot_id): - # TODO @cayop adding filter - # https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56 - import pdb; pdb.set_trace() - type_device = { - None: ['Desktop', 'Laptop', 'Server'], - 'Computer': ['Computer'], - 'Monitor': ['Monitor'], - } - filter_types = type_device[request.get('filter')] + form_filter = FilterForm() + filter_types = form_filter.search() + lots = Lot.query.outerjoin(Trade) \ .filter(or_(Trade.user_from == g.user, Trade.user_to == g.user, @@ -61,7 +56,6 @@ class DeviceListMix(View): ) if lot_id: - # import pdb; pdb.set_trace() lot = lots.filter(Lot.id == lot_id).one() devices = [dev for dev in lot.devices if dev.type in filter_types] devices = sorted(devices, key=lambda x: x.updated, reverse=True) @@ -98,6 +92,7 @@ class DeviceListMix(View): 'form_new_allocate': form_new_allocate, 'form_new_datawipe': form_new_datawipe, 'form_new_trade': form_new_trade, + 'form_filter': form_filter, 'lot': lot, 'tags': tags, 'list_devices': list_devices, diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 4170318d..ae545734 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -280,11 +280,17 @@
Computers
- - +
+
+ {% for f in form_filter %} + {{ f }} + {% endfor %} +
+
+ +
+
+
Select allSelect Title DHID Tags
From 34aab019b9db7897311447eb394138544c1e2d85 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Mar 2022 13:09:11 +0100 Subject: [PATCH 09/31] fix computer option --- ereuse_devicehub/inventory/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 945270b4..1c0981ff 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -49,7 +49,7 @@ class FilterForm(FlaskForm): type_device = { None: ['Desktop', 'Laptop', 'Server'], - 'Computer': ['Computer'], + 'Computer': ['Desktop', 'Laptop', 'Server'], 'Monitor': ['Monitor'], } return type_device.get(request.args.get('filter')) or type_device[None] From bd716e2ef881a45dea66c876491b7f13cea7c505 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Mar 2022 15:17:03 +0100 Subject: [PATCH 10/31] add more devices to the filter --- ereuse_devicehub/inventory/forms.py | 67 ++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 1c0981ff..e2499f0f 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -37,7 +37,60 @@ from sqlalchemy import or_ DEVICES = [ ("Computer", "Computer"), + ("Desktop", "Desktop"), + ("Laptop", "Laptop"), + ("Server", "Server"), ("Monitor", "Monitor"), + ("ComputerMonitor", "ComputerMonitor"), + ("TelevisionSet", "TelevisionSet"), + ("Projector", "Projector"), + ("Mobile", "Mobile"), + ("Smartphone", "Smartphone"), + ("Tablet", "Tablet"), + ("Cellphone", "Cellphone"), + ("JoinedComponentTableMixin", "JoinedComponentTableMixin"), + ("GraphicCard", "GraphicCard"), + ("DataStorage", "DataStorage"), + ("HardDrive", "HardDrive"), + ("SolidStateDrive", "SolidStateDrive"), + ("Motherboard", "Motherboard"), + ("NetworkMixin", "NetworkMixin"), + ("NetworkAdapter", "NetworkAdapter"), + ("Processor", "Processor"), + ("RamModule", "RamModule"), + ("SoundCard", "SoundCard"), + ("Display", "Display"), + ("Battery", "Battery"), + ("Camera", "Camera"), + ("ComputerAccessory", "ComputerAccessory"), + ("SAI", "SAI"), + ("Keyboard", "Keyboard"), + ("Mouse", "Mouse"), + ("MemoryCardReader", "MemoryCardReader"), + ("Networking", "Networking"), + ("Router", "Router"), + ("Switch", "Switch"), + ("Hub", "Hub"), + ("WirelessAccessPoint", "WirelessAccessPoint"), + ("Printer", "Printer"), + ("LabelPrinter", "LabelPrinter"), + ("Sound", "Sound"), + ("Microphone", "Microphone"), + ("Video", "Video"), + ("VideoScaler", "VideoScaler"), + ("Videoconference", "Videoconference"), + ("Cooking", "Cooking"), + ("Mixer", "Mixer"), + ("DIYAndGardening", "DIYAndGardening"), + ("Drill", "Drill"), + ("PackOfScrewdrivers", "PackOfScrewdrivers"), + ("Home", "Home"), + ("Dehumidifier", "Dehumidifier"), + ("Stairs", "Stairs"), + ("Recreation", "Recreation"), + ("Bike", "Bike"), + ("Racket", "Racket"), + ("Manufacturer", "Manufacturer") ] @@ -46,13 +99,15 @@ class FilterForm(FlaskForm): render_kw={'class': "form-select"}) def search(self): + device = dict(DEVICES).get(request.args.get('filter')) - type_device = { - None: ['Desktop', 'Laptop', 'Server'], - 'Computer': ['Desktop', 'Laptop', 'Server'], - 'Monitor': ['Monitor'], - } - return type_device.get(request.args.get('filter')) or type_device[None] + if device == "Computer": + return ['Desktop', 'Laptop', 'Server'] + + if device: + return [device] + + return ['Desktop', 'Laptop', 'Server'] class LotDeviceForm(FlaskForm): From 62f42e9e0562aec53a71427e180d8516affa2e98 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 10:15:21 +0100 Subject: [PATCH 11/31] fix bug --- ereuse_devicehub/inventory/forms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index e2499f0f..6b3955de 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -36,6 +36,7 @@ from sqlalchemy import or_ DEVICES = [ + ("All", "All"), ("Computer", "Computer"), ("Desktop", "Desktop"), ("Laptop", "Laptop"), @@ -95,7 +96,7 @@ DEVICES = [ class FilterForm(FlaskForm): - filter = SelectField('', choices=DEVICES, default="Comupter", + filter = SelectField('', choices=DEVICES, default="Computer", render_kw={'class': "form-select"}) def search(self): From a983ebd6cf111e82116456f1501580bee455614b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 10:15:53 +0100 Subject: [PATCH 12/31] add all devices as option in the select of filter --- ereuse_devicehub/inventory/views.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 9c4d2e10..f9629e59 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -57,7 +57,9 @@ class DeviceListMix(View): if lot_id: lot = lots.filter(Lot.id == lot_id).one() - devices = [dev for dev in lot.devices if dev.type in filter_types] + devices = lot.devices + if 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) form_new_action = NewActionForm(lot=lot.id) form_new_allocate = AllocateForm(lot=lot.id) @@ -68,12 +70,20 @@ class DeviceListMix(View): user_from=g.user.email, ) else: - devices = ( - Device.query.filter(Device.owner_id == current_user.id) - .filter(Device.type.in_(filter_types)) - .filter_by(lots=None) - .order_by(Device.updated.desc()) - ) + if "All" in filter_types: + devices = ( + Device.query.filter(Device.owner_id == current_user.id) + .filter_by(lots=None) + .order_by(Device.updated.desc()) + ) + else: + devices = ( + Device.query.filter(Device.owner_id == current_user.id) + .filter_by(lots=None) + .filter(Device.type.in_(filter_types)) + .order_by(Device.updated.desc()) + ) + form_new_action = NewActionForm() form_new_allocate = AllocateForm() form_new_datawipe = DataWipeForm() From ea66c31a079cbaaf3ea43c8055bfe3f3028c06f5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 10:30:53 +0100 Subject: [PATCH 13/31] fix bug --- ereuse_devicehub/inventory/forms.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 91b80305..fae58678 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -98,14 +98,22 @@ class FilterForm(FlaskForm): filter = SelectField('', choices=DEVICES, default="Computer", render_kw={'class': "form-select"}) - def search(self): - device = dict(DEVICES).get(request.args.get('filter')) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.device = dict(DEVICES).get(request.args.get('filter')) + if self.device: + self.filter.data = self.device - if device == "Computer": + def search(self): + + if self.device == "Computer": return ['Desktop', 'Laptop', 'Server'] - if device: - return [device] + if self.device == "DataStorage": + return ['HardDrive', 'SolidStateDrive'] + + if self.device: + return [self.device] return ['Desktop', 'Laptop', 'Server'] From b16fdd59f97d49f1a3d007caa255501bba86e67c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 11:01:10 +0100 Subject: [PATCH 14/31] precommit --- ereuse_devicehub/inventory/forms.py | 86 ++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 26 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index fae58678..82a1b639 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1,26 +1,46 @@ import copy import json from json.decoder import JSONDecodeError + from boltons.urlutils import URL from flask import g, request from flask_wtf import FlaskForm +from sqlalchemy import or_ from sqlalchemy.util import OrderedSet from wtforms import ( - BooleanField, DateField, FileField, FloatField, Form, HiddenField, - IntegerField, MultipleFileField, SelectField, StringField, TextAreaField, - URLField, validators) + BooleanField, + DateField, + FileField, + FloatField, + Form, + HiddenField, + IntegerField, + MultipleFileField, + SelectField, + StringField, + TextAreaField, + URLField, + validators, +) from wtforms.fields import FormField from ereuse_devicehub.db import db -from ereuse_devicehub.resources.action.models import RateComputer, Snapshot +from ereuse_devicehub.resources.action.models import RateComputer, Snapshot, Trade from ereuse_devicehub.resources.action.rate.v1_0 import CannotRate -from ereuse_devicehub.resources.action.schemas import \ - Snapshot as SnapshotSchema -from ereuse_devicehub.resources.action.views.snapshot import ( - move_json, save_json) +from ereuse_devicehub.resources.action.schemas import Snapshot as SnapshotSchema +from ereuse_devicehub.resources.action.views.snapshot import move_json, save_json from ereuse_devicehub.resources.device.models import ( - SAI, Cellphone, Computer, Device, Keyboard, MemoryCardReader, Monitor, - Mouse, Smartphone, Tablet) + SAI, + Cellphone, + Computer, + Device, + Keyboard, + MemoryCardReader, + Monitor, + Mouse, + Smartphone, + Tablet, +) from ereuse_devicehub.resources.device.sync import Sync from ereuse_devicehub.resources.documents.models import DataWipeDocument from ereuse_devicehub.resources.enums import Severity, SnapshotSoftware @@ -30,9 +50,6 @@ from ereuse_devicehub.resources.tag.model import Tag from ereuse_devicehub.resources.tradedocument.models import TradeDocument from ereuse_devicehub.resources.user.exceptions import InsufficientPermission from ereuse_devicehub.resources.user.models import User -from ereuse_devicehub.resources.action.models import Trade -from sqlalchemy import or_ - DEVICES = [ ("All", "All"), @@ -90,13 +107,14 @@ DEVICES = [ ("Recreation", "Recreation"), ("Bike", "Bike"), ("Racket", "Racket"), - ("Manufacturer", "Manufacturer") + ("Manufacturer", "Manufacturer"), ] class FilterForm(FlaskForm): - filter = SelectField('', choices=DEVICES, default="Computer", - render_kw={'class': "form-select"}) + filter = SelectField( + '', choices=DEVICES, default="Computer", render_kw={'class': "form-select"} + ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -131,9 +149,14 @@ class LotDeviceForm(FlaskForm): self._lot = ( Lot.query.outerjoin(Trade) .filter(Lot.id == self.lot.data) - .filter(or_(Trade.user_from == g.user, - Trade.user_to == g.user, - Lot.owner_id == g.user.id)).one() + .filter( + or_( + Trade.user_from == g.user, + Trade.user_to == g.user, + Lot.owner_id == g.user.id, + ) + ) + .one() ) devices = set(self.devices.data.split(",")) @@ -550,11 +573,17 @@ class TagDeviceForm(FlaskForm): super().__init__(*args, **kwargs) if self.delete: - tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by( - device_id=self.device_id - ).order_by(Tag.id) + tags = ( + Tag.query.filter(Tag.owner_id == g.user.id) + .filter_by(device_id=self.device_id) + .order_by(Tag.id) + ) else: - tags = Tag.query.filter(Tag.owner_id == g.user.id).filter_by(device_id=None).order_by(Tag.id) + tags = ( + Tag.query.filter(Tag.owner_id == g.user.id) + .filter_by(device_id=None) + .order_by(Tag.id) + ) self.tag.choices = [(tag.id, tag.id) for tag in tags] @@ -813,9 +842,14 @@ class TradeForm(NewActionForm): self._lot = ( Lot.query.outerjoin(Trade) .filter(Lot.id == self.lot.data) - .filter(or_(Trade.user_from == g.user, - Trade.user_to == g.user, - Lot.owner_id == g.user.id)).one() + .filter( + or_( + Trade.user_from == g.user, + Trade.user_to == g.user, + Lot.owner_id == g.user.id, + ) + ) + .one() ) def validate(self, extra_validators=None): From 2f84aac7efe9146a7b7a6af8c355cb58a0a11e86 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 8 Mar 2022 17:59:33 +0100 Subject: [PATCH 15/31] change the title of list when there are a select data in the filter --- ereuse_devicehub/templates/inventory/device_list.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 9a08b4f6..8ed8de70 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -279,7 +279,11 @@
-
Computers
+ {% if form_filter.filter.data %} +
{{ form_filter.filter.data }}
+ {% else %} +
Computer
+ {% endif %}
From 71926f01c0f939af41c3230d0a7d2d931ce9c109 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Mar 2022 09:16:01 +0100 Subject: [PATCH 16/31] new list of device for filter --- ereuse_devicehub/inventory/forms.py | 45 +++++-------------- .../templates/inventory/device_list.html | 39 ++++++++++++++++ 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index ae827195..6861947b 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -53,11 +53,9 @@ from ereuse_devicehub.resources.user.models import User DEVICES = [ ("All", "All"), - ("Computer", "Computer"), ("Desktop", "Desktop"), ("Laptop", "Laptop"), ("Server", "Server"), - ("Monitor", "Monitor"), ("ComputerMonitor", "ComputerMonitor"), ("TelevisionSet", "TelevisionSet"), ("Projector", "Projector"), @@ -65,49 +63,30 @@ DEVICES = [ ("Smartphone", "Smartphone"), ("Tablet", "Tablet"), ("Cellphone", "Cellphone"), - ("JoinedComponentTableMixin", "JoinedComponentTableMixin"), ("GraphicCard", "GraphicCard"), - ("DataStorage", "DataStorage"), ("HardDrive", "HardDrive"), ("SolidStateDrive", "SolidStateDrive"), ("Motherboard", "Motherboard"), - ("NetworkMixin", "NetworkMixin"), ("NetworkAdapter", "NetworkAdapter"), ("Processor", "Processor"), ("RamModule", "RamModule"), ("SoundCard", "SoundCard"), - ("Display", "Display"), ("Battery", "Battery"), - ("Camera", "Camera"), - ("ComputerAccessory", "ComputerAccessory"), - ("SAI", "SAI"), ("Keyboard", "Keyboard"), ("Mouse", "Mouse"), ("MemoryCardReader", "MemoryCardReader"), - ("Networking", "Networking"), - ("Router", "Router"), - ("Switch", "Switch"), - ("Hub", "Hub"), - ("WirelessAccessPoint", "WirelessAccessPoint"), - ("Printer", "Printer"), - ("LabelPrinter", "LabelPrinter"), - ("Sound", "Sound"), - ("Microphone", "Microphone"), - ("Video", "Video"), - ("VideoScaler", "VideoScaler"), - ("Videoconference", "Videoconference"), - ("Cooking", "Cooking"), - ("Mixer", "Mixer"), - ("DIYAndGardening", "DIYAndGardening"), - ("Drill", "Drill"), - ("PackOfScrewdrivers", "PackOfScrewdrivers"), - ("Home", "Home"), - ("Dehumidifier", "Dehumidifier"), - ("Stairs", "Stairs"), - ("Recreation", "Recreation"), - ("Bike", "Bike"), - ("Racket", "Racket"), - ("Manufacturer", "Manufacturer"), + ("GraphicCard", "GraphicCard"), + ("HardDrive", "HardDrive"), + ("SolidStateDrive", "SolidStateDrive"), + ("Motherboard", "Motherboard"), + ("NetworkAdapter", "NetworkAdapter"), + ("Processor", "Processor"), + ("RamModule", "RamModule"), + ("SoundCard", "SoundCard"), + ("Battery", "Battery"), + ("Keyboard", "Keyboard"), + ("Mouse", "Mouse"), + ("MemoryCardReader", "MemoryCardReader"), ] diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index eacbda29..08cb18ea 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -296,7 +296,46 @@
{% for f in form_filter %} + {% if f == form_filter.filter %} + + {% else %} {{ f }} + {% endif %} {% endfor %}
From d20bd63caedbacbb066c4b43749a7596a9a1748c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Mar 2022 10:02:30 +0100 Subject: [PATCH 17/31] precommit --- ereuse_devicehub/inventory/forms.py | 70 +++++++------------ .../templates/inventory/device_list.html | 39 ----------- 2 files changed, 26 insertions(+), 83 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 6861947b..5eab3236 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -51,43 +51,29 @@ from ereuse_devicehub.resources.tradedocument.models import TradeDocument from ereuse_devicehub.resources.user.exceptions import InsufficientPermission from ereuse_devicehub.resources.user.models import User -DEVICES = [ - ("All", "All"), - ("Desktop", "Desktop"), - ("Laptop", "Laptop"), - ("Server", "Server"), - ("ComputerMonitor", "ComputerMonitor"), - ("TelevisionSet", "TelevisionSet"), - ("Projector", "Projector"), - ("Mobile", "Mobile"), - ("Smartphone", "Smartphone"), - ("Tablet", "Tablet"), - ("Cellphone", "Cellphone"), - ("GraphicCard", "GraphicCard"), - ("HardDrive", "HardDrive"), - ("SolidStateDrive", "SolidStateDrive"), - ("Motherboard", "Motherboard"), - ("NetworkAdapter", "NetworkAdapter"), - ("Processor", "Processor"), - ("RamModule", "RamModule"), - ("SoundCard", "SoundCard"), - ("Battery", "Battery"), - ("Keyboard", "Keyboard"), - ("Mouse", "Mouse"), - ("MemoryCardReader", "MemoryCardReader"), - ("GraphicCard", "GraphicCard"), - ("HardDrive", "HardDrive"), - ("SolidStateDrive", "SolidStateDrive"), - ("Motherboard", "Motherboard"), - ("NetworkAdapter", "NetworkAdapter"), - ("Processor", "Processor"), - ("RamModule", "RamModule"), - ("SoundCard", "SoundCard"), - ("Battery", "Battery"), - ("Keyboard", "Keyboard"), - ("Mouse", "Mouse"), - ("MemoryCardReader", "MemoryCardReader"), -] +DEVICES = { + "All": ["All"], + "Computer": [ + "Desktop", + "Laptop", + "Server", + ], + "Monitor": ["ComputerMonitor", "Monitor", "TelevisionSet", "Projector"], + "Mobile, tablet & smartphone": ["Mobile", "Tablet", "Smartphone", "Cellphone"], + "DataStorage": ["HardDrive", "SolidStateDrive"], + "Accessories & Peripherals": [ + "GraphicCard", + "Motherboard", + "NetworkAdapter", + "Processor", + "RamModule", + "SoundCard", + "Battery", + "Keyboard", + "Mouse", + "MemoryCardReader", + ], +} class FilterForm(FlaskForm): @@ -97,18 +83,14 @@ class FilterForm(FlaskForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.device = dict(DEVICES).get(request.args.get('filter')) + types_of_devices = [item for sublist in DEVICES.values() for item in sublist] + dev = request.args.get('filter') + self.device = dev if dev in types_of_devices else None if self.device: self.filter.data = self.device def search(self): - if self.device == "Computer": - return ['Desktop', 'Laptop', 'Server'] - - if self.device == "DataStorage": - return ['HardDrive', 'SolidStateDrive'] - if self.device: return [self.device] diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index 08cb18ea..eacbda29 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -296,46 +296,7 @@
{% for f in form_filter %} - {% if f == form_filter.filter %} - - {% else %} {{ f }} - {% endif %} {% endfor %}
From 678dfb0ea95f33623a874a6c46b01a6a5ec9cb86 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 10:59:55 +0100 Subject: [PATCH 18/31] Refactor filter form HTML markup Avoid using row & col --- .../templates/inventory/device_list.html | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index eacbda29..bce1cd23 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -286,25 +286,20 @@ {% endif %}
- - {% if form_filter.filter.data %} -
{{ form_filter.filter.data }}
- {% else %} -
Computer
- {% endif %} -
-
- {% for f in form_filter %} - {{ f }} - {% endfor %} -
-
- -
-
+
+ {% for f in form_filter %} + {{ f }} + {% endfor %} +
+ +

+ Displaying devices of type + {{ form_filter.filter.data or "Computer" }} +

+
From b2cc66cb8646d4488e2833f81954863fbd9cc5c3 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 11 Mar 2022 19:16:39 +0100 Subject: [PATCH 19/31] modify Changelog.md --- CHANGELOG.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83520944..96d64604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.ht ml). -## master - [1.0.12-beta] -## testing - [1.0.13-beta] - -## [1.0.13-beta] +## [2.0.0-alpha] +- [changes] #209 adding a new device in a lot if it is created from a lot +- [addend] #208 render from backend filter for type of devices in the general list +- [bugfix] #206 fix 2 bugs about visibility devices when you are not the owner +- [addend] #205 ux improvements +- [addend] #204 render from backend export files +- [addend] #203 render from backend Trade action +- [addend] #201 render from backend Data Wipe action +- [addend] #196 render from backend action system +- [addend] #195 render from backend tags system +- [addend] #193 render from backend devices and lots +- [changes] #191 pass to drop teal and use the pure flask and use render from flask ## [1.0.12-beta] - [changes] #187 now is possible duplicate slots of RAM. From 7da68a908056ab4d978c00801c4a8669e8c5bf63 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 14 Mar 2022 17:21:28 +0100 Subject: [PATCH 20/31] fix type of changes --- CHANGELOG.md | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d64604..236e689e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,31 +7,31 @@ ml). ## [2.0.0-alpha] -- [changes] #209 adding a new device in a lot if it is created from a lot -- [addend] #208 render from backend filter for type of devices in the general list -- [bugfix] #206 fix 2 bugs about visibility devices when you are not the owner -- [addend] #205 ux improvements -- [addend] #204 render from backend export files -- [addend] #203 render from backend Trade action -- [addend] #201 render from backend Data Wipe action -- [addend] #196 render from backend action system -- [addend] #195 render from backend tags system -- [addend] #193 render from backend devices and lots -- [changes] #191 pass to drop teal and use the pure flask and use render from flask +- [changed] #209 adding a new device in a lot if it is created from a lot +- [added] #208 render from backend filter for type of devices in the general list +- [fixed] #206 fix 2 bugs about visibility devices when you are not the owner +- [added] #205 ux improvements +- [added] #204 render from backend export files +- [added] #203 render from backend Trade action +- [added] #201 render from backend Data Wipe action +- [added] #196 render from backend action system +- [added] #195 render from backend tags system +- [added] #193 render from backend devices and lots +- [changed] #191 pass to drop teal and use the pure flask and use render from flask ## [1.0.12-beta] -- [changes] #187 now is possible duplicate slots of RAM. -- [changes] #188 Excel report devices allow to see device to old owners. +- [changed] #187 now is possible duplicate slots of RAM. +- [changed] #188 Excel report devices allow to see device to old owners. ## [1.0.11-beta] -- [addend] #186 adding property power_on_hours. +- [added] #186 adding property power_on_hours. ## [1.0.10-beta] -- [addend] #170 can delete/deactivate devices. -- [bugfix] #168 can to do a trade without devices. +- [added] #170 can delete/deactivate devices. +- [fixed] #168 can to do a trade without devices. - [added] #167 new actions of status devices: use, recycling, refurbish and management. -- [changes] #177 new structure of trade. -- [bugfix] #184 clean nested of schemas of lot +- [changed] #177 new structure of trade. +- [fixed] #184 clean nested of schemas of lot - [added] #182 adding power on hours ## [1.0.9-beta] @@ -40,7 +40,7 @@ ml). ## [1.0.8-beta] -- [bugfix] #161 fixing DataStorage with bigInteger +- [fixed] #161 fixing DataStorage with bigInteger ## [1.0.7-beta] - [added] #158 support for encrypted snapshots data @@ -48,25 +48,25 @@ ml). - [added] #140 adding endpoint for download the settings for usb workbench ## [1.0.6-beta] -- [bugfix] #143 biginteger instead of integer in TestDataStorage +- [fixed] #143 biginteger instead of integer in TestDataStorage ## [1.0.5-beta] - [added] #124 adding endpoint for extract the internal stats of use - [added] #122 system for verify all documents that it's produced from devicehub - [added] #127 add one code for every named tag - [added] #131 add one code for every device -- [bugfix] #138 search device with devicehubId +- [fixed] #138 search device with devicehubId ## [1.0.4-beta] - [added] #95 adding endpoint for check the hash of one report - [added] #98 adding endpoint for insert a new live - [added] #98 adding endpoint for get all licences in one query - [added] #102 adding endpoint for download metrics -- [bugfix] #100 fixing bug of scheme live -- [bugfix] #101 fixing bug when 2 users have one device and launch one live -- [changes] #114 clean blockchain of all models -- [changes] #118 deactivate manual merge -- [changes] #118 clean datas of public information of devices +- [fixed] #100 fixing bug of scheme live +- [fixed] #101 fixing bug when 2 users have one device and launch one live +- [changed] #114 clean blockchain of all models +- [changed] #118 deactivate manual merge +- [changed] #118 clean datas of public information of devices - [remove] #114 remove proof system ## [1.0.3-beta] From 0458cf8c7d5ab8bf96e3d8475f5e35f046972dd2 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 14 Mar 2022 17:26:40 +0100 Subject: [PATCH 21/31] empty versions for testing and master --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 236e689e..782d6ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.ht ml). +## master + [] + +## testing + [] ## [2.0.0-alpha] - [changed] #209 adding a new device in a lot if it is created from a lot From 8bdd119008289e737099d8c30693fe1938be7e34 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Mar 2022 09:18:14 +0100 Subject: [PATCH 22/31] . --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 782d6ef0..0387921d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ml). ## master - [] ## testing - [] ## [2.0.0-alpha] - [changed] #209 adding a new device in a lot if it is created from a lot @@ -72,7 +70,7 @@ ml). - [changed] #114 clean blockchain of all models - [changed] #118 deactivate manual merge - [changed] #118 clean datas of public information of devices -- [remove] #114 remove proof system +- [removed] #114 remove proof system ## [1.0.3-beta] - [added] #85 add mac of network adapter to device hid From 278f6c9a3f7b4ac38ad993dafdd88a3787893c3a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Mar 2022 09:31:09 +0100 Subject: [PATCH 23/31] The same types of changes should be grouped --- CHANGELOG.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0387921d..0e637fa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,7 @@ ml). ## testing ## [2.0.0-alpha] -- [changed] #209 adding a new device in a lot if it is created from a lot - [added] #208 render from backend filter for type of devices in the general list -- [fixed] #206 fix 2 bugs about visibility devices when you are not the owner - [added] #205 ux improvements - [added] #204 render from backend export files - [added] #203 render from backend Trade action @@ -20,7 +18,9 @@ ml). - [added] #196 render from backend action system - [added] #195 render from backend tags system - [added] #193 render from backend devices and lots +- [changed] #209 adding a new device in a lot if it is created from a lot - [changed] #191 pass to drop teal and use the pure flask and use render from flask +- [fixed] #206 fix 2 bugs about visibility devices when you are not the owner ## [1.0.12-beta] - [changed] #187 now is possible duplicate slots of RAM. @@ -31,11 +31,11 @@ ml). ## [1.0.10-beta] - [added] #170 can delete/deactivate devices. -- [fixed] #168 can to do a trade without devices. - [added] #167 new actions of status devices: use, recycling, refurbish and management. -- [changed] #177 new structure of trade. -- [fixed] #184 clean nested of schemas of lot - [added] #182 adding power on hours +- [changed] #177 new structure of trade. +- [fixed] #168 can to do a trade without devices. +- [fixed] #184 clean nested of schemas of lot ## [1.0.9-beta] - [added] #159 external document as proof of erase of disk @@ -65,11 +65,11 @@ ml). - [added] #98 adding endpoint for insert a new live - [added] #98 adding endpoint for get all licences in one query - [added] #102 adding endpoint for download metrics -- [fixed] #100 fixing bug of scheme live -- [fixed] #101 fixing bug when 2 users have one device and launch one live - [changed] #114 clean blockchain of all models - [changed] #118 deactivate manual merge - [changed] #118 clean datas of public information of devices +- [fixed] #100 fixing bug of scheme live +- [fixed] #101 fixing bug when 2 users have one device and launch one live - [removed] #114 remove proof system ## [1.0.3-beta] @@ -78,6 +78,6 @@ ml). ## [1.0.2-beta] - [added] #87 allocate, deallocate and live actions -- [fixed] #89 save json on disk only for shapshots - [added] #83 add owner_id in all kind of device +- [fixed] #89 save json on disk only for shapshots - [fixed] #91 The most old time allow is 1970-01-01 From 57e9a7ef9aef8990f749ff80baab82e4a7e0afdc Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 11:12:53 +0100 Subject: [PATCH 24/31] Include version of DeviceHub (hardcoded) on footer --- ereuse_devicehub/templates/ereuse_devicehub/base_site.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index f9c1e075..8799068c 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -209,14 +209,14 @@
- Designed by BootstrapMade + Designed by BootstrapMade // DeviceHub v2.0.0a2
From b4b12da477e96a93c8fdfd1ed32d85d8d3c02b07 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 15 Mar 2022 11:46:32 +0100 Subject: [PATCH 25/31] Add of DeviceHub in template --- ereuse_devicehub/__init__.py | 2 +- ereuse_devicehub/inventory/views.py | 38 +++++++++++++++---- .../templates/ereuse_devicehub/base_site.html | 2 +- ereuse_devicehub/views.py | 5 ++- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ereuse_devicehub/__init__.py b/ereuse_devicehub/__init__.py index c69e4574..688b5e56 100644 --- a/ereuse_devicehub/__init__.py +++ b/ereuse_devicehub/__init__.py @@ -1 +1 @@ -__version__ = "1.0.12-beta" +__version__ = "2.0.0-alpha" diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 57a67454..4ead3005 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -11,7 +11,7 @@ from requests.exceptions import ConnectionError from sqlalchemy import or_ from werkzeug.exceptions import NotFound -from ereuse_devicehub import messages +from ereuse_devicehub import __version__, messages from ereuse_devicehub.db import db from ereuse_devicehub.inventory.forms import ( AllocateForm, @@ -122,6 +122,7 @@ class DeviceListMix(GenericMixView): 'lot': lot, 'tags': tags, 'list_devices': list_devices, + 'version': __version__, } return self.context @@ -149,6 +150,7 @@ class DeviceDetailView(GenericMixView): 'device': device, 'lots': lots, 'page_title': 'Device {}'.format(device.devicehub_id), + 'version': __version__, } return flask.render_template(self.template_name, **context) @@ -207,7 +209,12 @@ class LotCreateView(GenericMixView): return flask.redirect(next_url) lots = self.get_lots() - context = {'form': form, 'title': self.title, 'lots': lots} + context = { + 'form': form, + 'title': self.title, + 'lots': lots, + 'version': __version__, + } return flask.render_template(self.template_name, **context) @@ -225,7 +232,12 @@ class LotUpdateView(View): return flask.redirect(next_url) lots = Lot.query.filter(Lot.owner_id == current_user.id) - context = {'form': form, 'title': self.title, 'lots': lots} + context = { + 'form': form, + 'title': self.title, + 'lots': lots, + 'version': __version__, + } return flask.render_template(self.template_name, **context) @@ -260,6 +272,7 @@ class UploadSnapshotView(GenericMixView): 'lots': lots, 'form': form, 'lot_id': lot_id, + 'version': __version__, } if form.validate_on_submit(): snapshot = form.save(commit=False) @@ -285,6 +298,7 @@ class DeviceCreateView(GenericMixView): 'lots': lots, 'form': form, 'lot_id': lot_id, + 'version': __version__, } if form.validate_on_submit(): snapshot = form.save(commit=False) @@ -314,6 +328,7 @@ class TagListView(View): 'lots': lots, 'tags': tags, 'page_title': 'Tags Management', + 'version': __version__, } return flask.render_template(self.template_name, **context) @@ -325,7 +340,7 @@ class TagAddView(View): def dispatch_request(self): lots = Lot.query.filter(Lot.owner_id == current_user.id) - context = {'page_title': 'New Tag', 'lots': lots} + context = {'page_title': 'New Tag', 'lots': lots, 'version': __version__} form = TagForm() if form.validate_on_submit(): form.save() @@ -342,7 +357,11 @@ class TagAddUnnamedView(View): def dispatch_request(self): lots = Lot.query.filter(Lot.owner_id == current_user.id) - context = {'page_title': 'New Unnamed Tag', 'lots': lots} + context = { + 'page_title': 'New Unnamed Tag', + 'lots': lots, + 'version': __version__, + } form = TagUnnamedForm() if form.validate_on_submit(): try: @@ -377,6 +396,7 @@ class TagDetailView(View): 'lots': lots, 'tag': tag, 'page_title': '{} Tag'.format(tag.code), + 'version': __version__, } return flask.render_template(self.template_name, **context) @@ -409,7 +429,11 @@ class TagUnlinkDeviceView(View): return flask.redirect(next_url) return flask.render_template( - self.template_name, form=form, lots=lots, referrer=request.referrer + self.template_name, + form=form, + lots=lots, + referrer=request.referrer, + version=__version__, ) @@ -522,7 +546,7 @@ class NewTradeDocumentView(View): return flask.redirect(next_url) return flask.render_template( - self.template_name, form=self.form, title=self.title + self.template_name, form=self.form, title=self.title, version=__version__ ) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index 8799068c..a84cea66 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -216,7 +216,7 @@ - Designed by BootstrapMade // DeviceHub v2.0.0a2 + Designed by BootstrapMade // DeviceHub {{ version }} diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index 6ad67aac..a79b0f53 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -3,6 +3,7 @@ from flask import Blueprint from flask.views import View from flask_login import current_user, login_required, login_user, logout_user +from ereuse_devicehub import __version__ from ereuse_devicehub.forms import LoginForm from ereuse_devicehub.resources.user.models import User from ereuse_devicehub.utils import is_safe_url @@ -31,7 +32,8 @@ class LoginView(View): return flask.redirect( next_url or flask.url_for('inventory.devices.devicelist') ) - return flask.render_template('ereuse_devicehub/user_login.html', form=form) + context = {'form': form, 'version': __version__} + return flask.render_template('ereuse_devicehub/user_login.html', **context) class LogoutView(View): @@ -47,6 +49,7 @@ class UserProfileView(View): def dispatch_request(self): context = { 'current_user': current_user, + 'version': __version__, } return flask.render_template(self.template_name, **context) From 754f75eab4d5c8736bac102fc0b85566a259036b Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 14:33:27 +0100 Subject: [PATCH 26/31] Rename base URL 'inventory.devices' => 'inventory' --- ereuse_devicehub/inventory/views.py | 31 +++++++++---------- .../templates/ereuse_devicehub/base_site.html | 14 ++++----- .../templates/inventory/actions.html | 2 +- .../templates/inventory/addDeviceslot.html | 2 +- .../templates/inventory/addDevicestag.html | 2 +- .../templates/inventory/allocate.html | 2 +- .../templates/inventory/data_wipe.html | 2 +- .../templates/inventory/device_create.html | 6 ++-- .../templates/inventory/device_detail.html | 2 +- .../templates/inventory/device_list.html | 20 ++++++------ ereuse_devicehub/templates/inventory/lot.html | 4 +-- .../templates/inventory/removeDeviceslot.html | 2 +- .../templates/inventory/removelot.html | 2 +- .../templates/inventory/tag_create.html | 4 +-- .../inventory/tag_create_unnamed.html | 4 +-- .../templates/inventory/tag_detail.html | 6 ++-- .../templates/inventory/tag_list.html | 8 ++--- .../inventory/tag_unlink_device.html | 2 +- .../templates/inventory/trade.html | 2 +- .../templates/inventory/trade_document.html | 4 +-- .../templates/inventory/upload_snapshot.html | 6 ++-- ereuse_devicehub/views.py | 4 +-- 22 files changed, 64 insertions(+), 67 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 4ead3005..4e827be4 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -35,8 +35,7 @@ from ereuse_devicehub.resources.hash_reports import insert_hash from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.tag.model import Tag -# TODO(@slamora): rename base 'inventory.devices' --> 'inventory' -devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') +devices = Blueprint('inventory', __name__, url_prefix='/inventory') logger = logging.getLogger(__name__) @@ -171,7 +170,7 @@ class LotDeviceAddView(View): else: messages.error('Error adding devices to lot!') - next_url = request.referrer or url_for('inventory.devices.devicelist') + next_url = request.referrer or url_for('inventory.devicelist') return flask.redirect(next_url) @@ -191,7 +190,7 @@ class LotDeviceDeleteView(View): else: messages.error('Error removing devices from lot!') - next_url = request.referrer or url_for('inventory.devices.devicelist') + next_url = request.referrer or url_for('inventory.devicelist') return flask.redirect(next_url) @@ -205,7 +204,7 @@ class LotCreateView(GenericMixView): form = LotForm() if form.validate_on_submit(): form.save() - next_url = url_for('inventory.devices.lotdevicelist', lot_id=form.id) + next_url = url_for('inventory.lotdevicelist', lot_id=form.id) return flask.redirect(next_url) lots = self.get_lots() @@ -228,7 +227,7 @@ class LotUpdateView(View): form = LotForm(id=id) if form.validate_on_submit(): form.save() - next_url = url_for('inventory.devices.lotdevicelist', lot_id=id) + next_url = url_for('inventory.lotdevicelist', lot_id=id) return flask.redirect(next_url) lots = Lot.query.filter(Lot.owner_id == current_user.id) @@ -251,11 +250,11 @@ class LotDeleteView(View): if form.instance.trade: msg = "Sorry, the lot cannot be deleted because have a trade action " messages.error(msg) - next_url = url_for('inventory.devices.lotdevicelist', lot_id=id) + next_url = url_for('inventory.lotdevicelist', lot_id=id) return flask.redirect(next_url) form.remove() - next_url = url_for('inventory.devices.devicelist') + next_url = url_for('inventory.devicelist') return flask.redirect(next_url) @@ -302,9 +301,9 @@ class DeviceCreateView(GenericMixView): } if form.validate_on_submit(): snapshot = form.save(commit=False) - next_url = url_for('inventory.devices.devicelist') + next_url = url_for('inventory.devicelist') if lot_id: - next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id) + next_url = url_for('inventory.lotdevicelist', lot_id=lot_id) lot = lots.filter(Lot.id == lot_id).one() lot.devices.add(snapshot.device) db.session.add(lot) @@ -344,7 +343,7 @@ class TagAddView(View): form = TagForm() if form.validate_on_submit(): form.save() - next_url = url_for('inventory.devices.taglist') + next_url = url_for('inventory.taglist') return flask.redirect(next_url) return flask.render_template(self.template_name, form=form, **context) @@ -376,7 +375,7 @@ class TagAddUnnamedView(View): ) messages.error(msg) - next_url = url_for('inventory.devices.taglist') + next_url = url_for('inventory.taglist') return flask.redirect(next_url) return flask.render_template(self.template_name, form=form, **context) @@ -425,7 +424,7 @@ class TagUnlinkDeviceView(View): if form.validate_on_submit(): form.remove() - next_url = url_for('inventory.devices.devicelist') + next_url = url_for('inventory.devicelist') return flask.redirect(next_url) return flask.render_template( @@ -458,9 +457,9 @@ class NewActionView(View): lot_id = self.form.lot.data if lot_id: - return url_for('inventory.devices.lotdevicelist', lot_id=lot_id) + return url_for('inventory.lotdevicelist', lot_id=lot_id) - return url_for('inventory.devices.devicelist') + return url_for('inventory.devicelist') class NewAllocateView(NewActionView, DeviceListMix): @@ -542,7 +541,7 @@ class NewTradeDocumentView(View): if self.form.validate_on_submit(): self.form.save() messages.success('Document created successfully!') - next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id) + next_url = url_for('inventory.lotdevicelist', lot_id=lot_id) return flask.redirect(next_url) return flask.render_template( diff --git a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html index a84cea66..5d87be53 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/base_site.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/base_site.html @@ -5,7 +5,7 @@
diff --git a/ereuse_devicehub/templates/inventory/lot.html b/ereuse_devicehub/templates/inventory/lot.html index dfad3241..0a5d81b2 100644 --- a/ereuse_devicehub/templates/inventory/lot.html +++ b/ereuse_devicehub/templates/inventory/lot.html @@ -44,9 +44,9 @@
{% if form.id %} - Cancel + Cancel {% else %} - Cancel + Cancel {% endif %}
diff --git a/ereuse_devicehub/templates/inventory/removeDeviceslot.html b/ereuse_devicehub/templates/inventory/removeDeviceslot.html index 1a00dabf..186bcaf6 100644 --- a/ereuse_devicehub/templates/inventory/removeDeviceslot.html +++ b/ereuse_devicehub/templates/inventory/removeDeviceslot.html @@ -6,7 +6,7 @@ - + {{ form_lot_device.csrf_token }}
- Cancel + Cancel
diff --git a/ereuse_devicehub/templates/inventory/tag_create_unnamed.html b/ereuse_devicehub/templates/inventory/tag_create_unnamed.html index a72099d4..d8eddde0 100644 --- a/ereuse_devicehub/templates/inventory/tag_create_unnamed.html +++ b/ereuse_devicehub/templates/inventory/tag_create_unnamed.html @@ -5,7 +5,7 @@

{{ title }}

@@ -49,7 +49,7 @@
- Cancel + Cancel
diff --git a/ereuse_devicehub/templates/inventory/tag_detail.html b/ereuse_devicehub/templates/inventory/tag_detail.html index 3e63ff50..691838df 100644 --- a/ereuse_devicehub/templates/inventory/tag_detail.html +++ b/ereuse_devicehub/templates/inventory/tag_detail.html @@ -5,7 +5,7 @@

Inventory

@@ -33,7 +33,7 @@
Device
{% if tag.device %} - + {{ tag.device.verbose_name }} {% endif %} @@ -109,6 +109,6 @@ {% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/tag_list.html b/ereuse_devicehub/templates/inventory/tag_list.html index b385dfc8..28ecc8f8 100644 --- a/ereuse_devicehub/templates/inventory/tag_list.html +++ b/ereuse_devicehub/templates/inventory/tag_list.html @@ -20,7 +20,7 @@
{% for tag in tags %} - +
- + {{ dev.verbose_name }} - + {{ dev.devicehub_id }} {% for t in dev.tags | sort(attribute="id") %} - {{ t.id }} + {{ t.id }} {% if not loop.last %},{% endif %} {% endfor %}
{{ tag.id }}{{ tag.id }} {% if tag.provider %}Unnamed tag {% else %}Named tag{% endif %} {{ tag.get_provider }} {% if tag.device %} - + {{ tag.device.verbose_name }} {% endif %} diff --git a/ereuse_devicehub/templates/inventory/tag_unlink_device.html b/ereuse_devicehub/templates/inventory/tag_unlink_device.html index fc6d49d6..47b5ce8f 100644 --- a/ereuse_devicehub/templates/inventory/tag_unlink_device.html +++ b/ereuse_devicehub/templates/inventory/tag_unlink_device.html @@ -4,7 +4,7 @@
diff --git a/ereuse_devicehub/templates/inventory/trade.html b/ereuse_devicehub/templates/inventory/trade.html index ae106cba..1a73093f 100644 --- a/ereuse_devicehub/templates/inventory/trade.html +++ b/ereuse_devicehub/templates/inventory/trade.html @@ -9,7 +9,7 @@
-
+ {{ form_new_trade.csrf_token }} - {{ form.csrf_token }} {% for field in form %} @@ -51,7 +51,7 @@ {% endfor %}
- Cancel + Cancel
diff --git a/ereuse_devicehub/templates/inventory/upload_snapshot.html b/ereuse_devicehub/templates/inventory/upload_snapshot.html index e4f07abd..cef1a0c3 100644 --- a/ereuse_devicehub/templates/inventory/upload_snapshot.html +++ b/ereuse_devicehub/templates/inventory/upload_snapshot.html @@ -5,7 +5,7 @@

Inventory

@@ -56,9 +56,9 @@
{% if lot_id %} - Cancel + Cancel {% else %} - Cancel + Cancel {% endif %}
diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index a79b0f53..3ca1db3c 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -29,9 +29,7 @@ class LoginView(View): if not is_safe_url(flask.request, next_url): return flask.abort(400) - return flask.redirect( - next_url or flask.url_for('inventory.devices.devicelist') - ) + return flask.redirect(next_url or flask.url_for('inventory.devicelist')) context = {'form': form, 'version': __version__} return flask.render_template('ereuse_devicehub/user_login.html', **context) From 8fdce31ee6535ae478280492dd55d87c38f87624 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 14:37:54 +0100 Subject: [PATCH 27/31] Sort by task number DESC (v2.0.0-alpha release) --- CHANGELOG.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e637fa9..5eb71013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,16 +10,18 @@ ml). ## testing ## [2.0.0-alpha] -- [added] #208 render from backend filter for type of devices in the general list -- [added] #205 ux improvements -- [added] #204 render from backend export files -- [added] #203 render from backend Trade action -- [added] #201 render from backend Data Wipe action -- [added] #196 render from backend action system -- [added] #195 render from backend tags system -- [added] #193 render from backend devices and lots -- [changed] #209 adding a new device in a lot if it is created from a lot +First server render HTML version. Completely rewrites views of angular JS client on flask. +- [added] #193 render on backend devices and lots +- [added] #195 render on backend tags system +- [added] #196 render on backend action system +- [added] #201 render on backend Data Wipe action +- [added] #203 render on backend Trade action +- [added] #204 render on backend export files +- [added] #205 UX improvements +- [added] #208 render on backend filter for type of devices in the general list - [changed] #191 pass to drop teal and use the pure flask and use render from flask +- [changed] #207 Create automatic tag only for Computers. +- [changed] #209 adding a new device in a lot if it is created from a lot - [fixed] #206 fix 2 bugs about visibility devices when you are not the owner ## [1.0.12-beta] From 8085700009e49fa6c2a9f8532ddaa49e421e061a Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 14:41:26 +0100 Subject: [PATCH 28/31] Hide "remember be" until it is implemented --- ereuse_devicehub/templates/ereuse_devicehub/user_login.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ereuse_devicehub/templates/ereuse_devicehub/user_login.html b/ereuse_devicehub/templates/ereuse_devicehub/user_login.html index fa80daba..b234927c 100644 --- a/ereuse_devicehub/templates/ereuse_devicehub/user_login.html +++ b/ereuse_devicehub/templates/ereuse_devicehub/user_login.html @@ -48,12 +48,14 @@
Please enter your password!
+
From b0cf3a097813f749156f72c39915a68b3d94f1e7 Mon Sep 17 00:00:00 2001 From: Santiago L Date: Tue, 15 Mar 2022 14:42:37 +0100 Subject: [PATCH 29/31] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e26265b1..63a0458c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,6 @@ repos: rev: 5.9.3 hooks: - id: isort - # args: ["--profile", "black", "--filter-files"] - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 hooks: From 24e489b9bb3544ee1e7114b02c26f57c0c8b0a28 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 15:01:27 +0100 Subject: [PATCH 30/31] Release version 2.0.0 First server side render version. Completely rewrites views of angular JS client on flask. --- CHANGELOG.md | 2 +- ereuse_devicehub/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eb71013..4e7d9b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ml). ## testing -## [2.0.0-alpha] +## [2.0.0] - 2022-03-15 First server render HTML version. Completely rewrites views of angular JS client on flask. - [added] #193 render on backend devices and lots - [added] #195 render on backend tags system diff --git a/ereuse_devicehub/__init__.py b/ereuse_devicehub/__init__.py index 688b5e56..8c0d5d5b 100644 --- a/ereuse_devicehub/__init__.py +++ b/ereuse_devicehub/__init__.py @@ -1 +1 @@ -__version__ = "2.0.0-alpha" +__version__ = "2.0.0" From 8d3cad48bf67d95fbd6063e274aadb4842517688 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 15 Mar 2022 15:07:02 +0100 Subject: [PATCH 31/31] Bump to version 2.1.0.dev --- ereuse_devicehub/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/__init__.py b/ereuse_devicehub/__init__.py index 8c0d5d5b..4bf535c4 100644 --- a/ereuse_devicehub/__init__.py +++ b/ereuse_devicehub/__init__.py @@ -1 +1 @@ -__version__ = "2.0.0" +__version__ = "2.1.0.dev"