fix lower datas and image

This commit is contained in:
Cayo Puigdefabregas 2022-01-21 11:07:15 +01:00
parent f497cc03e5
commit 31b1806912

View file

@ -259,10 +259,6 @@ class NewDeviceForm(FlaskForm):
if not self.depth.data: if not self.depth.data:
self.depth.data = 0.1 self.depth.data = 0.1
if self.type.data:
self.instance = self.devices[self.type.data]()
self.populate_obj(self.instance)
def validate(self, extra_validators=None): def validate(self, extra_validators=None):
is_valid = super().validate(extra_validators) is_valid = super().validate(extra_validators)
@ -284,9 +280,20 @@ class NewDeviceForm(FlaskForm):
if self.depth.data < 0.1: if self.depth.data < 0.1:
return False return False
if self.image.data == '':
self.image.data = None
if self.manufacturer.data:
self.manufacturer.data = self.manufacturer.data.lower()
if self.model.data:
self.model.data = self.model.data.lower()
if self.serial_number.data:
self.serial_number.data = self.serial_number.data.lower()
return True return True
def save(self): def save(self):
self.instance = self.devices[self.type.data]()
self.populate_obj(self.instance)
db.session.add(self.instance) db.session.add(self.instance)
import pdb; pdb.set_trace() import pdb; pdb.set_trace()
db.session.commit() db.session.commit()