From 7d341c7d649be5e7cb42ca921519fb8653a9d19c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 5 Jan 2022 12:13:44 +0100 Subject: [PATCH] adding rendering template for new action --- ereuse_devicehub/inventory/forms.py | 14 +++++++---- ereuse_devicehub/inventory/views.py | 3 ++- ereuse_devicehub/static/js/main_inventory.js | 9 +++++++ .../templates/inventory/actions.html | 24 ++++++++++++++++--- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 701e73a7..bfee0d23 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1,5 +1,5 @@ from flask_wtf import FlaskForm -from wtforms import StringField, validators +from wtforms import StringField, HiddenField, DateField, TextAreaField, SelectField, validators from flask import g from ereuse_devicehub.db import db @@ -78,10 +78,14 @@ class LotForm(FlaskForm): class NewActionForm(FlaskForm): - name = StringField(u'Name') - date = StringField(u'Date') - severity = StringField(u'Severity') - description = StringField(u'Description') + name = StringField(u'Name', [validators.length(max=50)]) + devices = HiddenField() + date = DateField(u'Date') + severity = SelectField(u'Severity', choices=[('Info', 'Ok'), + ('Notice', 'Notice'), + ('Warning', 'Warning'), + ('Error', 'Error')]) + description = TextAreaField(u'Description') def save(self): pass diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 55ed61e8..2bf63365 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -5,7 +5,7 @@ from flask_login import login_required, current_user from ereuse_devicehub.resources.lot.models import Lot from ereuse_devicehub.resources.device.models import Device -from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm +from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, NewActionForm devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') @@ -30,6 +30,7 @@ class DeviceListView(View): context = {'devices': devices, 'lots': lots, 'form_lot_device': LotDeviceForm(), + 'form_new_action': NewActionForm(), 'lot': lot} return flask.render_template(self.template_name, **context) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 1f1b6d4c..12a12bae 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -9,15 +9,24 @@ function deviceSelect() { if (devices_id == "") { $("#addingLotModal .text-danger").show(); $("#addingLotModal .btn-primary").hide(); + $("#removeLotModal .text-danger").show(); $("#removeLotModal .btn-primary").hide(); + + $("#actionModal .text-danger").show(); + $("#actionModal .btn-primary").hide(); } else { $("#addingLotModal .text-danger").hide(); $("#addingLotModal .btn-primary").removeClass('d-none'); $("#addingLotModal .btn-primary").show(); + $("#removeLotModal .text-danger").hide(); $("#removeLotModal .btn-primary").removeClass('d-none'); $("#removeLotModal .btn-primary").show(); + + $("#actionModal .text-danger").hide(); + $("#actionModal .btn-primary").removeClass('d-none'); + $("#actionModal .btn-primary").show(); } $.map($(".devicesList"), function(x) { $(x).val(devices_id); diff --git a/ereuse_devicehub/templates/inventory/actions.html b/ereuse_devicehub/templates/inventory/actions.html index 2800c921..4e8151da 100644 --- a/ereuse_devicehub/templates/inventory/actions.html +++ b/ereuse_devicehub/templates/inventory/actions.html @@ -8,15 +8,33 @@
- {{ form_lot_device.csrf_token }} + {{ form_new_action.csrf_token }} +