show a error message creating placeholder device
This commit is contained in:
parent
2d7e1fdffd
commit
6a6c0e5182
|
@ -261,10 +261,13 @@ class DeviceCreateView(GenericMixin):
|
||||||
next_url = url_for('inventory.devicelist')
|
next_url = url_for('inventory.devicelist')
|
||||||
if lot_id:
|
if lot_id:
|
||||||
next_url = url_for('inventory.lotdevicelist', lot_id=lot_id)
|
next_url = url_for('inventory.lotdevicelist', lot_id=lot_id)
|
||||||
|
if snapshot and snapshot.device:
|
||||||
lots = self.context['lots']
|
lots = self.context['lots']
|
||||||
lot = lots.filter(Lot.id == lot_id).one()
|
lot = lots.filter(Lot.id == lot_id).one()
|
||||||
lot.devices.add(snapshot.device)
|
lot.devices.add(snapshot.device)
|
||||||
db.session.add(lot)
|
db.session.add(lot)
|
||||||
|
else:
|
||||||
|
messages.error('Sorry, the device could not be created')
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
messages.success('Device "{}" created successfully!'.format(form.type.data))
|
messages.success('Device "{}" created successfully!'.format(form.type.data))
|
||||||
|
|
Reference in New Issue