Skip to content

Commit

Permalink
Lookup workflow action redirect URL from request first (senaite#2083)
Browse files Browse the repository at this point in the history
* Lookup redirect URL from request

* Changelog updated

Co-authored-by: Jordi Puiggené <jp@naralabs.com>
  • Loading branch information
ramonski and xispa committed Aug 1, 2022
1 parent 2c3152e commit 5b3b7d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
2.3.0 (unreleased)
------------------

- #2083 Lookup workflow action redirect URL from request first
- #2082 Include sample ID in form ID for lab, field and qc analyses listings
- #2075 Allow to override logo and styles in new SENAITE Setup
- #2076 Fix style of selected language in dropdown
Expand Down
12 changes: 11 additions & 1 deletion src/bika/lims/browser/workflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@ def redirect(self, redirect_url=None, message=None, level="info"):
"""Redirect with a message
"""
if redirect_url is None:
redirect_url = self.back_url
redirect_url = self.get_redirect_url()
if message is not None:
self.add_status_message(message, level)
return self.request.response.redirect(redirect_url)

def get_redirect_url(self):
"""Lookup the redirect URL
"""
# Allow to set redirect_url in the request
redirect_url = self.request.get("redirect_url")
if not redirect_url:
# fall back to view attribute
return self.back_url
return redirect_url

def add_status_message(self, message, level="info"):
"""Set a portal status message
"""
Expand Down

0 comments on commit 5b3b7d8

Please sign in to comment.