save the organisation to the session after the user visits an org page

also remove the service/org from the session if the user is on a diff
type page, to make sure the redirects from /services-or-dashboard plays
nicely
This commit is contained in:
Leo Hemsted
2018-03-07 18:30:26 +00:00
parent dc5c3ba2b8
commit 04bfc362a2

View File

@@ -144,7 +144,7 @@ def create_app(application):
def init_app(application):
application.after_request(useful_headers_after_request)
application.after_request(save_service_after_request)
application.after_request(save_service_or_org_after_request)
application.before_request(load_service_before_request)
application.before_request(load_organisation_before_request)
application.before_request(request_helper.check_proxy_header_before_request)
@@ -446,11 +446,17 @@ def load_organisation_before_request():
raise
def save_service_after_request(response):
def save_service_or_org_after_request(response):
# Only save the current session if the request is 200
service_id = request.view_args.get('service_id', None) if request.view_args else None
if response.status_code == 200 and service_id:
session['service_id'] = service_id
organisation_id = request.view_args.get('org_id', None) if request.view_args else None
if response.status_code == 200:
if service_id:
session['service_id'] = service_id
session['organisation_id'] = None
elif organisation_id:
session['service_id'] = None
session['organisation_id'] = organisation_id
return response