From f79abb05cd2b4c39c8da653ccc6044924d560a82 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Feb 2022 10:50:36 +0100 Subject: [PATCH 01/10] isort --- ereuse_devicehub/inventory/forms.py | 35 +++++++++++++++++------------ ereuse_devicehub/inventory/views.py | 18 +++++++++------ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 83efbd89..89c8c835 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1,24 +1,31 @@ import json -from flask_wtf import FlaskForm -from wtforms import StringField, validators, MultipleFileField, FloatField, IntegerField, \ - HiddenField, DateField, TextAreaField, SelectField -from flask import g, request -from sqlalchemy.util import OrderedSet from json.decoder import JSONDecodeError +from flask import g, request +from flask_wtf import FlaskForm +from sqlalchemy.util import OrderedSet +from wtforms import (DateField, FloatField, HiddenField, IntegerField, + MultipleFileField, SelectField, StringField, + TextAreaField, validators) + from ereuse_devicehub.db import db -from ereuse_devicehub.resources.device.models import Device, Computer, Smartphone, Cellphone, \ - Tablet, Monitor, Mouse, Keyboard, \ - MemoryCardReader, SAI -from ereuse_devicehub.resources.action.models import Action, RateComputer, Snapshot, VisualTest -from ereuse_devicehub.resources.action.schemas import Snapshot as SnapshotSchema +from ereuse_devicehub.resources.action.models import (Action, RateComputer, + Snapshot, VisualTest) +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.device.models import (SAI, Cellphone, Computer, + Device, Keyboard, + MemoryCardReader, + Monitor, Mouse, + Smartphone, Tablet) +from ereuse_devicehub.resources.device.sync import Sync +from ereuse_devicehub.resources.enums import Severity, SnapshotSoftware from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.tag.model import Tag -from ereuse_devicehub.resources.enums import SnapshotSoftware, Severity from ereuse_devicehub.resources.user.exceptions import InsufficientPermission -from ereuse_devicehub.resources.action.rate.v1_0 import CannotRate -from ereuse_devicehub.resources.device.sync import Sync -from ereuse_devicehub.resources.action.views.snapshot import save_json, move_json class LotDeviceForm(FlaskForm): diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 29dcc78f..70dd5e53 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -1,14 +1,18 @@ -import flask import datetime -from flask.views import View -from flask import Blueprint, url_for, request -from flask_login import login_required, current_user +import flask +from flask import Blueprint, request, url_for +from flask.views import View +from flask_login import current_user, login_required + +from ereuse_devicehub.inventory.forms import (AllocateForm, LotDeviceForm, + LotForm, NewActionForm, + NewDeviceForm, TagDeviceForm, + TagForm, TagUnnamedForm, + UploadSnapshotForm) +from ereuse_devicehub.resources.device.models import Device 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, UploadSnapshotForm, \ - NewDeviceForm, TagForm, TagUnnamedForm, TagDeviceForm, NewActionForm, AllocateForm # TODO(@slamora): rename base 'inventory.devices' --> 'inventory' devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') From e8b5c1e310bfa9e53ce83a8ba5d79025fcabe40e Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Feb 2022 10:51:48 +0100 Subject: [PATCH 02/10] deactive dataWipe action --- ereuse_devicehub/templates/inventory/device_list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index df849ba9..ead573bf 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -139,7 +139,7 @@
  • - + DataWipe From 820078dd3f3ecb43dc13cea91653976a9aecb75d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Feb 2022 11:44:51 +0100 Subject: [PATCH 03/10] UX: inform user about the type action thas is going to be created --> show type of action --- ereuse_devicehub/static/js/main_inventory.js | 2 ++ ereuse_devicehub/templates/inventory/actions.html | 2 +- ereuse_devicehub/templates/inventory/allocate.html | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index c2fa6f8f..32067cbc 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -52,10 +52,12 @@ function removeTag() { function newAction(action) { $("#actionModal #type").val(action); + $("#actionModal #title-action").html(action); $("#activeActionModal").click(); } function newAllocate(action) { $("#allocateModal #type").val(action); + $("#allocateModal #title-action").html(action); $("#activeAllocateModal").click(); } diff --git a/ereuse_devicehub/templates/inventory/actions.html b/ereuse_devicehub/templates/inventory/actions.html index 61a942c5..2e14f24d 100644 --- a/ereuse_devicehub/templates/inventory/actions.html +++ b/ereuse_devicehub/templates/inventory/actions.html @@ -3,7 +3,7 @@