Redirect from normal dashboard to broadcast dashboard

There are lots of places where we redirect people to the dashboard, for
example after logging in. Rather than add logic to all these places to
check for the broadcast permission, let’s just redirect from the normal
dashboard to the broadcast dashboard.

Other places like the main navigation can still link directly to the
broadcast dashboard, where we do care about speed and not going through
multiple redirect jumps.
This commit is contained in:
Chris Hill-Scott
2020-07-08 11:39:04 +01:00
parent 6ec9a25dd1
commit 5c52d3c362
2 changed files with 19 additions and 0 deletions

View File

@@ -52,6 +52,9 @@ def service_dashboard(service_id):
session.pop('invited_user', None)
session['service_id'] = service_id
if current_service.has_permission('broadcast'):
return redirect(url_for('main.broadcast_dashboard', service_id=service_id))
if not current_user.has_permissions('view_activity'):
return redirect(url_for('main.choose_template', service_id=service_id))

View File

@@ -26,6 +26,22 @@ def test_broadcast_pages_403_without_permission(
)
def test_dashboard_redirects_to_broadcast_dashboard(
client_request,
service_one,
):
service_one['permissions'] += ['broadcast']
client_request.get(
'.service_dashboard',
service_id=SERVICE_ONE_ID,
_expected_redirect=url_for(
'.broadcast_dashboard',
service_id=SERVICE_ONE_ID,
_external=True,
),
),
def test_broadcast_dashboard(
client_request,
service_one,