3924 redirect cancel to reffered

This commit is contained in:
Cayo Puigdefabregas 2022-10-10 09:08:12 +02:00
parent 1d48515008
commit 50882ee56a
2 changed files with 9 additions and 2 deletions

View File

@ -756,6 +756,8 @@ class NewTransferView(GenericMixin):
def dispatch_request(self, type_id, lot_id=None):
self.form = self.form_class(lot_id=lot_id, type=type_id)
self.get_context()
referrer = request.referrer or url_for('inventory.devicelist')
self.context.update({'referrer': referrer})
if self.form.validate_on_submit():
self.form.save()
@ -767,7 +769,12 @@ class NewTransferView(GenericMixin):
next_url = url_for('inventory.lotdevicelist', lot_id=str(new_lot_id))
return flask.redirect(next_url)
self.context.update({'form': self.form, 'title': self.title})
self.context.update(
{
'form': self.form,
'title': self.title,
}
)
return flask.render_template(self.template_name, **self.context)

View File

@ -55,7 +55,7 @@
{% endfor %}
<div>
<a href="{{ url_for('inventory.lotdevicelist', lot_id=form._tmp_lot.id) }}" class="btn btn-danger">Cancel</a>
<a href="{{ referrer }}" class="btn btn-danger">Cancel</a>
<button class="btn btn-primary" type="submit">Save</button>
</div>
</form>