From 0018034fcda3608438ea0009b1391b550b3f5c20 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 26 Jan 2022 11:48:37 +0100 Subject: [PATCH] fix referrer path for redirect pages --- ereuse_devicehub/inventory/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index a670342f..67d65126 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -61,7 +61,8 @@ class LotDeviceAddView(View): if form.validate_on_submit(): form.save() - return flask.redirect(request.referrer) + next_url = request.referrer or url_for('inventory.devices.devicelist') + return flask.redirect(next_url) class LotDeviceDeleteView(View): @@ -74,8 +75,8 @@ class LotDeviceDeleteView(View): if form.validate_on_submit(): form.remove() - # TODO @cayop It's possible this redirect not work in production - return flask.redirect(request.referrer) + next_url = request.referrer or url_for('inventory.devices.devicelist') + return flask.redirect(next_url) class LotCreateView(View):