allocate formulary

This commit is contained in:
Cayo Puigdefabregas 2022-01-10 15:53:11 +01:00
parent 86d607800a
commit 5eb8a5a4b9
4 changed files with 26 additions and 4 deletions

View File

@ -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)])

View File

@ -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)

View File

@ -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();
}

View File

@ -79,6 +79,7 @@
New Actions
</button>
<span class="d-none" id="activeActionModal" data-bs-toggle="modal" data-bs-target="#actionModal"></span>
<span class="d-none" id="activeAllocateModal" data-bs-toggle="modal" data-bs-target="#allocateModal"></span>
<ul class="dropdown-menu" aria-labelledby="btnActions"">
<li>
Status actions
@ -111,13 +112,13 @@
Allocation
</li>
<li>
<a href="javascript:newAction('Allocate')" class="dropdown-item">
<a href="javascript:newAllocate('Allocate')" class="dropdown-item">
<i class="bi bi-house-fill"></i>
Allocate
</a>
</li>
<li>
<a href="javascript:newAction('Deallocate')" class="dropdown-item">
<a href="javascript:newAllocate('Deallocate')" class="dropdown-item">
<i class="bi bi-house"></i>
Deallocate
</a>
@ -245,6 +246,7 @@
{% include "inventory/addinglot.html" %}
{% include "inventory/removinglot.html" %}
{% include "inventory/actions.html" %}
{% include "inventory/allocate.html" %}
<!-- CDN -->
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest"></script>