fix doble query
This commit is contained in:
parent
8149d0ed7c
commit
71f5a8a98b
|
@ -418,7 +418,6 @@ class TagDeviceForm(FlaskForm):
|
||||||
self.delete = kwargs.pop('delete', None)
|
self.delete = kwargs.pop('delete', None)
|
||||||
self.device_id = kwargs.pop('device', None)
|
self.device_id = kwargs.pop('device', None)
|
||||||
|
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
if self.delete:
|
if self.delete:
|
||||||
|
@ -479,12 +478,13 @@ class NewActionForm(FlaskForm):
|
||||||
if not is_valid:
|
if not is_valid:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
devices = set(self.devices.data.split(","))
|
if self.devices.data:
|
||||||
self._devices = OrderedSet(Device.query.filter(Device.id.in_(devices)).filter(
|
devices = set(self.devices.data.split(","))
|
||||||
Device.owner_id == g.user.id).all())
|
self._devices = OrderedSet(Device.query.filter(Device.id.in_(devices)).filter(
|
||||||
|
Device.owner_id == g.user.id).all())
|
||||||
|
|
||||||
if not self._devices:
|
if not self._devices:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -497,12 +497,12 @@ class NewActionForm(FlaskForm):
|
||||||
self.severity.data = Severity[self.severity.data]
|
self.severity.data = Severity[self.severity.data]
|
||||||
|
|
||||||
self.populate_obj(self.instance)
|
self.populate_obj(self.instance)
|
||||||
|
db.session.add(self.instance)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
self.devices.data = devices
|
self.devices.data = devices
|
||||||
self.severity.data = severity
|
self.severity.data = severity
|
||||||
|
|
||||||
db.session.add(self.instance)
|
|
||||||
db.session.commit()
|
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -297,11 +297,12 @@ class NewAllocateView(NewActionView, DeviceListMix):
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
dispatch = super().dispatch_request()
|
dispatch = super().dispatch_request()
|
||||||
if self.form.validate_on_submit():
|
if dispatch.status_code == 302:
|
||||||
return dispatch
|
return dispatch
|
||||||
|
|
||||||
# lot_id = self.form.lot.data
|
# lot_id = self.form.lot.data
|
||||||
# FIXME
|
# FIXME
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
self.get_context(None)
|
self.get_context(None)
|
||||||
return flask.render_template(self.template_name, **self.context)
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
||||||
|
|
Reference in New Issue