allocate formulary
This commit is contained in:
parent
86d607800a
commit
5eb8a5a4b9
|
@ -122,6 +122,10 @@ class NewActionForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class AllocateForm(NewActionForm):
|
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(),))
|
start_time = DateField(u'Start time', validators=(validators.Optional(),))
|
||||||
end_time = DateField(u'End 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)])
|
final_user_code = StringField(u'Final user code', [validators.length(max=50)])
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import flask
|
import flask
|
||||||
|
import datetime
|
||||||
from flask.views import View
|
from flask.views import View
|
||||||
from flask import Blueprint, url_for
|
from flask import Blueprint, url_for
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
from ereuse_devicehub.resources.lot.models import Lot
|
from ereuse_devicehub.resources.lot.models import Lot
|
||||||
from ereuse_devicehub.resources.device.models import Device
|
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')
|
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
|
||||||
|
|
||||||
|
@ -29,10 +31,14 @@ class DeviceListView(View):
|
||||||
Device.type.in_(filter_types))
|
Device.type.in_(filter_types))
|
||||||
form_new_action = NewActionForm()
|
form_new_action = NewActionForm()
|
||||||
|
|
||||||
|
allocate = AllocateForm(start_time=datetime.datetime.now(),
|
||||||
|
end_time=datetime.datetime.now())
|
||||||
|
|
||||||
context = {'devices': devices,
|
context = {'devices': devices,
|
||||||
'lots': lots,
|
'lots': lots,
|
||||||
'form_lot_device': LotDeviceForm(),
|
'form_lot_device': LotDeviceForm(),
|
||||||
'form_new_action': form_new_action,
|
'form_new_action': form_new_action,
|
||||||
|
'form_allocate': allocate,
|
||||||
'lot': lot}
|
'lot': lot}
|
||||||
return flask.render_template(self.template_name, **context)
|
return flask.render_template(self.template_name, **context)
|
||||||
|
|
||||||
|
@ -104,9 +110,10 @@ class NewActionView(View):
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
form = NewActionForm()
|
form = NewActionForm()
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
next_url = url_for('inventory.devices.devicelist')
|
next_url = url_for('inventory.devices.devicelist')
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
form.save()
|
# form.save()
|
||||||
if form.lot.data:
|
if form.lot.data:
|
||||||
next_url = url_for('inventory.devices.lotdevicelist', id=form.lot.data)
|
next_url = url_for('inventory.devices.lotdevicelist', id=form.lot.data)
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ function deviceSelect() {
|
||||||
$("#actionModal .text-danger").hide();
|
$("#actionModal .text-danger").hide();
|
||||||
$("#actionModal .btn-primary").removeClass('d-none');
|
$("#actionModal .btn-primary").removeClass('d-none');
|
||||||
$("#actionModal .btn-primary").show();
|
$("#actionModal .btn-primary").show();
|
||||||
|
|
||||||
|
$("#allocateModal .text-danger").hide();
|
||||||
|
$("#allocateModal .btn-primary").removeClass('d-none');
|
||||||
|
$("#allocateModal .btn-primary").show();
|
||||||
}
|
}
|
||||||
$.map($(".devicesList"), function(x) {
|
$.map($(".devicesList"), function(x) {
|
||||||
$(x).val(devices_id);
|
$(x).val(devices_id);
|
||||||
|
@ -37,3 +41,8 @@ function newAction(action) {
|
||||||
$("#actionModal #type").val(action);
|
$("#actionModal #type").val(action);
|
||||||
$("#activeActionModal").click();
|
$("#activeActionModal").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function newAllocate(action) {
|
||||||
|
$("#allocateModal #type").val(action);
|
||||||
|
$("#activeAllocateModal").click();
|
||||||
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
New Actions
|
New Actions
|
||||||
</button>
|
</button>
|
||||||
<span class="d-none" id="activeActionModal" data-bs-toggle="modal" data-bs-target="#actionModal"></span>
|
<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"">
|
<ul class="dropdown-menu" aria-labelledby="btnActions"">
|
||||||
<li>
|
<li>
|
||||||
Status actions
|
Status actions
|
||||||
|
@ -111,13 +112,13 @@
|
||||||
Allocation
|
Allocation
|
||||||
</li>
|
</li>
|
||||||
<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>
|
<i class="bi bi-house-fill"></i>
|
||||||
Allocate
|
Allocate
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:newAction('Deallocate')" class="dropdown-item">
|
<a href="javascript:newAllocate('Deallocate')" class="dropdown-item">
|
||||||
<i class="bi bi-house"></i>
|
<i class="bi bi-house"></i>
|
||||||
Deallocate
|
Deallocate
|
||||||
</a>
|
</a>
|
||||||
|
@ -245,6 +246,7 @@
|
||||||
{% include "inventory/addinglot.html" %}
|
{% include "inventory/addinglot.html" %}
|
||||||
{% include "inventory/removinglot.html" %}
|
{% include "inventory/removinglot.html" %}
|
||||||
{% include "inventory/actions.html" %}
|
{% include "inventory/actions.html" %}
|
||||||
|
{% include "inventory/allocate.html" %}
|
||||||
|
|
||||||
<!-- CDN -->
|
<!-- CDN -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest"></script>
|
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest"></script>
|
||||||
|
|
Reference in New Issue