fix the return correct page when the submit is false
This commit is contained in:
parent
c0918e7b57
commit
87faee3444
|
@ -295,21 +295,25 @@ class NewAllocateView(NewActionView, DeviceListMix):
|
||||||
methods = ['POST']
|
methods = ['POST']
|
||||||
_form = AllocateForm
|
_form = AllocateForm
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self, lot_id=None):
|
||||||
dispatch = super().dispatch_request()
|
next_url = url_for('inventory.devices.devicelist')
|
||||||
if dispatch:
|
if lot_id:
|
||||||
return dispatch
|
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
|
||||||
|
|
||||||
# lot_id = self.form.lot.data
|
self.form = self._form()
|
||||||
# FIXME
|
if self.form.validate_on_submit():
|
||||||
# import pdb; pdb.set_trace()
|
self.form.save()
|
||||||
self.get_context(None)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
self.get_context(lot_id)
|
||||||
self.context['form_new_allocate'] = self.form
|
self.context['form_new_allocate'] = self.form
|
||||||
return flask.render_template(self.template_name, **self.context)
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
||||||
|
|
||||||
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
||||||
devices.add_url_rule('/action/allocate/add/', view_func=NewAllocateView.as_view('allocate_add'))
|
devices.add_url_rule('/action/allocate/add/', view_func=NewAllocateView.as_view('allocate_add'))
|
||||||
|
devices.add_url_rule('/lot/<string:lot_id>/action/allocate/add/',
|
||||||
|
view_func=NewAllocateView.as_view('lot_allocate_add'))
|
||||||
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
||||||
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details'))
|
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details'))
|
||||||
devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
||||||
|
|
|
@ -8,7 +8,12 @@
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="{{ url_for('inventory.devices.allocate_add') }}" method="post">
|
<form action="
|
||||||
|
{% if lot %}
|
||||||
|
{{ url_for('inventory.devices.lot_allocate_add', lot_id=lot.id) }}
|
||||||
|
{% else %}
|
||||||
|
{{ url_for('inventory.devices.allocate_add') }}
|
||||||
|
{% endif %}" method="post">
|
||||||
{{ form_new_allocate.csrf_token }}
|
{{ form_new_allocate.csrf_token }}
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p class="text-danger" id="pol" style="display: none;">
|
<p class="text-danger" id="pol" style="display: none;">
|
||||||
|
|
Reference in New Issue