ux menu
This commit is contained in:
parent
a4aced0238
commit
3dae7e3a58
|
@ -388,12 +388,12 @@ class NewDeviceForm(FlaskForm):
|
|||
self.depth.errors = error
|
||||
is_valid = False
|
||||
|
||||
if self.imei.data:
|
||||
if self.imei.data and self.amount.data == 1:
|
||||
if not 13 < len(str(self.imei.data)) < 17:
|
||||
self.imei.errors = error
|
||||
is_valid = False
|
||||
|
||||
if self.meid.data:
|
||||
if self.meid.data and self.amount.data == 1:
|
||||
meid = self.meid.data
|
||||
if not 13 < len(meid) < 17:
|
||||
is_valid = False
|
||||
|
@ -407,7 +407,7 @@ class NewDeviceForm(FlaskForm):
|
|||
dev = Device.query.filter_by(
|
||||
hid=self.phid.data, owner=g.user, active=True
|
||||
).first()
|
||||
if dev and not dev.placeholder:
|
||||
if dev:
|
||||
msg = "Sorry, exist one snapshot device with this HID"
|
||||
self.phid.errors = [msg]
|
||||
is_valid = False
|
||||
|
@ -424,12 +424,26 @@ class NewDeviceForm(FlaskForm):
|
|||
if self.serial_number.data:
|
||||
self.serial_number.data = self.serial_number.data.lower()
|
||||
|
||||
if not self.phid.data:
|
||||
_hid = Placeholder.query.order_by(Placeholder.id.desc()).first()
|
||||
if _hid:
|
||||
_hid = str(_hid.id + 1)
|
||||
else:
|
||||
_hid = '1'
|
||||
self.phid.data = _hid.lower()
|
||||
self.phid.data = self.phid.data.lower()
|
||||
|
||||
if self.amount.data > 1:
|
||||
self.phid.data = None
|
||||
self.id_device_supplier.data = None
|
||||
self.serial_number.data = None
|
||||
self.sku.data = None
|
||||
self.imei.data = None
|
||||
self.meid.data = None
|
||||
|
||||
return True
|
||||
|
||||
def save(self, commit=True):
|
||||
if self.amount.data > 1:
|
||||
self.phid.data = None
|
||||
|
||||
for n in range(self.amount.data):
|
||||
self.create_device()
|
||||
|
||||
|
@ -486,20 +500,9 @@ class NewDeviceForm(FlaskForm):
|
|||
snapshot_json['device'].meid = self.meid.data
|
||||
|
||||
snapshot_json['device'].placeholder = self.get_placeholder()
|
||||
|
||||
_hid = self.phid.data
|
||||
if not _hid:
|
||||
_hid = Placeholder.query.order_by(Placeholder.id.desc()).first()
|
||||
if _hid:
|
||||
_hid = str(_hid.id + 1)
|
||||
else:
|
||||
_hid = '1'
|
||||
|
||||
snapshot_json['device'].hid = _hid.lower()
|
||||
|
||||
snapshot = upload_form.build(snapshot_json)
|
||||
|
||||
move_json(self.tmp_snapshots, path_snapshot, g.user.email)
|
||||
|
||||
if self.type.data == 'ComputerMonitor':
|
||||
snapshot.device.resolution = self.resolution.data
|
||||
snapshot.device.screen = self.screen.data
|
||||
|
|
|
@ -28,7 +28,17 @@ function deviceInputs() {
|
|||
function amountInputs() {
|
||||
if ($("#amount").val() > 1) {
|
||||
$("#Phid").hide();
|
||||
$("#Id_device_supplier").hide();
|
||||
$("#Serial_number").hide();
|
||||
$("#Sku").hide();
|
||||
$("#imei").hide();
|
||||
$("#meid").hide();
|
||||
} else {
|
||||
$("#Phid").show();
|
||||
$("#Id_device_supplier").show();
|
||||
$("#Serial_number").show();
|
||||
$("#Sku").show();
|
||||
$("#imei").show();
|
||||
$("#meid").show();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-2">
|
||||
<div class="form-group mb-2" id="Id_device_supplier">
|
||||
<label for="label" class="form-label">{{ form.id_device_supplier.label }}</label>
|
||||
{{ form.id_device_supplier(class_="form-control") }}
|
||||
<small class="text-muted form-text">Identity of device for the Supplier</small>
|
||||
|
@ -142,7 +142,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="from-group has-validation mb-2">
|
||||
<div class="from-group has-validation mb-2" id="Serial_number">
|
||||
<label for="serialNumber" class="form-label">{{ form.serial_number.label }}</label>
|
||||
{{ form.serial_number(class_="form-control") }}
|
||||
<small class="text-muted form-text">Serial number of this device</small>
|
||||
|
@ -349,7 +349,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="from-group has-validation mb-2">
|
||||
<div class="from-group has-validation mb-2" id="Sku">
|
||||
<label for="model" class="form-label">{{ form.sku.label }}</label>
|
||||
{{ form.sku(class_="form-control") }}
|
||||
<small class="text-muted form-text">The Stock Keeping Unit (SKU), i.e. a merchant-specific identifier for a product or service.</small>
|
||||
|
|
|
@ -315,7 +315,7 @@
|
|||
<div class="btn-group dropdown m-1" uib-dropdown="">
|
||||
<button id="btnSnapshot" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-laptop"></i>
|
||||
New Device
|
||||
New Devices
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
|
||||
<li>
|
||||
|
@ -325,7 +325,17 @@
|
|||
<a href="{{ url_for('inventory.upload_snapshot') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload a new Snapshot
|
||||
Upload Snapshot files
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
{% if lot %}
|
||||
<a href="{{ url_for('inventory.lot_upload_snapshot', lot_id=lot.id) }}" class="dropdown-item">
|
||||
{% else %}
|
||||
<a href="{{ url_for('inventory.upload_snapshot') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-upload"></i>
|
||||
Upload Placeholder Spreadsheet
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -335,7 +345,7 @@
|
|||
<a href="{{ url_for('inventory.device_add') }}" class="dropdown-item">
|
||||
{% endif %}
|
||||
<i class="bi bi-plus"></i>
|
||||
Create a new Device
|
||||
Create a new Placeholder
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -504,14 +504,14 @@ def test_update_monitor(user3: UserClientFlask):
|
|||
}
|
||||
body, status = user3.post(uri, data=data)
|
||||
assert status == '200 OK'
|
||||
assert 'Device "Monitor" created successfully!' in body
|
||||
assert 'Sorry, exist one snapshot device with this HID' in body
|
||||
dev = Device.query.one()
|
||||
assert dev.type == 'Monitor'
|
||||
assert dev.placeholder.id_device_supplier == "b3"
|
||||
assert dev.placeholder.id_device_supplier == "b2"
|
||||
assert dev.hid == '1'
|
||||
assert dev.model == 'lcd 43 b'
|
||||
assert dev.depth == 0.2
|
||||
assert dev.placeholder.pallet == "l20"
|
||||
assert dev.model == 'lc27t55'
|
||||
assert dev.depth == 0.1
|
||||
assert dev.placeholder.pallet == "l34"
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -628,7 +628,7 @@ def test_add_with_ammount_laptops(user3: UserClientFlask):
|
|||
for dev in Device.query.all():
|
||||
assert dev.type == 'Laptop'
|
||||
assert dev.placeholder.id_device_supplier == "b2"
|
||||
assert dev.hid in [str(x) for x in range(1, num+1)]
|
||||
assert dev.hid in [str(x) for x in range(1, num + 1)]
|
||||
assert Device.query.count() == num
|
||||
|
||||
|
||||
|
|
Reference in a new issue