diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 64bb58dd..8f8207b1 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -122,6 +122,10 @@ class NewActionForm(FlaskForm): class AllocateForm(NewActionForm): + def __init__(self, *args, **kwargs): + # import pdb; pdb.set_trace() + super().__init__(*args, **kwargs) + start_time = DateField(u'Start time', validators=(validators.Optional(),)) end_time = DateField(u'End time', validators=(validators.Optional(),)) final_user_code = StringField(u'Final user code', [validators.length(max=50)]) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index dec3544b..5f73bd0b 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -1,11 +1,13 @@ import flask +import datetime from flask.views import View 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.device.models import Device -from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, NewActionForm +from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, NewActionForm, \ + AllocateForm devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') @@ -29,10 +31,14 @@ class DeviceListView(View): Device.type.in_(filter_types)) form_new_action = NewActionForm() + allocate = AllocateForm(start_time=datetime.datetime.now(), + end_time=datetime.datetime.now()) + context = {'devices': devices, 'lots': lots, 'form_lot_device': LotDeviceForm(), 'form_new_action': form_new_action, + 'form_allocate': allocate, 'lot': lot} return flask.render_template(self.template_name, **context) @@ -104,9 +110,10 @@ class NewActionView(View): def dispatch_request(self): form = NewActionForm() + # import pdb; pdb.set_trace() next_url = url_for('inventory.devices.devicelist') if form.validate_on_submit(): - form.save() + # form.save() if form.lot.data: next_url = url_for('inventory.devices.lotdevicelist', id=form.lot.data) diff --git a/ereuse_devicehub/static/js/main_inventory.js b/ereuse_devicehub/static/js/main_inventory.js index 186bdd17..cb451465 100644 --- a/ereuse_devicehub/static/js/main_inventory.js +++ b/ereuse_devicehub/static/js/main_inventory.js @@ -27,6 +27,10 @@ function deviceSelect() { $("#actionModal .text-danger").hide(); $("#actionModal .btn-primary").removeClass('d-none'); $("#actionModal .btn-primary").show(); + + $("#allocateModal .text-danger").hide(); + $("#allocateModal .btn-primary").removeClass('d-none'); + $("#allocateModal .btn-primary").show(); } $.map($(".devicesList"), function(x) { $(x).val(devices_id); @@ -37,3 +41,8 @@ function newAction(action) { $("#actionModal #type").val(action); $("#activeActionModal").click(); } + +function newAllocate(action) { + $("#allocateModal #type").val(action); + $("#activeAllocateModal").click(); +} diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html index fb13f34d..d7b9a5f5 100644 --- a/ereuse_devicehub/templates/inventory/device_list.html +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -79,6 +79,7 @@ New Actions +