return error response in post request
This commit is contained in:
parent
e37fa49c3e
commit
f9be7f0a14
|
@ -315,16 +315,19 @@ class NewActionView(View):
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
self.form = self.form_class()
|
self.form = self.form_class()
|
||||||
|
next_url = self.get_next_url()
|
||||||
|
|
||||||
if self.form.validate_on_submit():
|
if self.form.validate_on_submit():
|
||||||
self.form.save()
|
self.form.save()
|
||||||
messages.success(
|
messages.success(
|
||||||
'Action "{}" created successfully!'.format(self.form.type.data)
|
'Action "{}" created successfully!'.format(self.form.type.data)
|
||||||
)
|
)
|
||||||
|
|
||||||
next_url = self.get_next_url()
|
next_url = self.get_next_url()
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
messages.error('Action {} error!'.format(self.form.type.data))
|
||||||
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
def get_next_url(self):
|
def get_next_url(self):
|
||||||
lot_id = self.form.lot.data
|
lot_id = self.form.lot.data
|
||||||
|
|
||||||
|
@ -350,10 +353,9 @@ class NewAllocateView(NewActionView, DeviceListMix):
|
||||||
next_url = self.get_next_url()
|
next_url = self.get_next_url()
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
lot_id = self.form.lot.data
|
messages.error('Action {} error!'.format(self.form.type.data))
|
||||||
self.get_context(lot_id)
|
next_url = self.get_next_url()
|
||||||
self.context['form_new_allocate'] = self.form
|
return flask.redirect(next_url)
|
||||||
return flask.render_template(self.template_name, **self.context)
|
|
||||||
|
|
||||||
|
|
||||||
class NewDataWipeView(NewActionView, DeviceListMix):
|
class NewDataWipeView(NewActionView, DeviceListMix):
|
||||||
|
@ -372,10 +374,9 @@ class NewDataWipeView(NewActionView, DeviceListMix):
|
||||||
next_url = self.get_next_url()
|
next_url = self.get_next_url()
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
lot_id = self.form.lot.data
|
messages.error('Action {} error!'.format(self.form.type.data))
|
||||||
self.get_context(lot_id)
|
next_url = self.get_next_url()
|
||||||
self.context['form_new_datawipe'] = self.form
|
return flask.redirect(next_url)
|
||||||
return flask.render_template(self.template_name, **self.context)
|
|
||||||
|
|
||||||
|
|
||||||
class NewTradeView(NewActionView, DeviceListMix):
|
class NewTradeView(NewActionView, DeviceListMix):
|
||||||
|
@ -394,10 +395,9 @@ class NewTradeView(NewActionView, DeviceListMix):
|
||||||
next_url = self.get_next_url()
|
next_url = self.get_next_url()
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
lot_id = self.form.lot.data
|
messages.error('Action {} error!'.format(self.form.type.data))
|
||||||
self.get_context(lot_id)
|
next_url = self.get_next_url()
|
||||||
self.context['form_new_trade'] = self.form
|
return flask.redirect(next_url)
|
||||||
return flask.render_template(self.template_name, **self.context)
|
|
||||||
|
|
||||||
|
|
||||||
class NewTradeDocumentView(View):
|
class NewTradeDocumentView(View):
|
||||||
|
|
Reference in New Issue