mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-14 23:08:07 -04:00
It’s a bit of a weird experience to be taken to the sign in screen when you click GOV.UK in the header. It’s doubly weird if you take the tour before creating an account, and at the end of the tour you get prompted to sign in. This commit adds some extra logic to take you to the homepage instead, which I think is more what you’d expect.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from flask import (render_template, redirect, url_for, session)
|
|
from flask_login import login_required, current_user
|
|
from app.main import main
|
|
from app import service_api_client
|
|
from app.notify_client.api_client import ServicesBrowsableItem
|
|
|
|
|
|
@main.route("/services")
|
|
@login_required
|
|
def choose_service():
|
|
return render_template(
|
|
'views/choose-service.html',
|
|
services=[ServicesBrowsableItem(x) for x in
|
|
service_api_client.get_services({'user_id': current_user.id})['data']]
|
|
)
|
|
|
|
|
|
@main.route("/services-or-dashboard")
|
|
def show_all_services_or_dashboard():
|
|
|
|
if not current_user.is_authenticated():
|
|
return redirect(url_for('.index'))
|
|
|
|
services = service_api_client.get_services({'user_id': current_user.id})['data']
|
|
|
|
if 1 == len(services):
|
|
return redirect(url_for('.service_dashboard', service_id=services[0]['id']))
|
|
else:
|
|
service_id = session.get('service_id', None)
|
|
if any([service_id == x['id'] for x in services]):
|
|
return redirect(url_for('.service_dashboard', service_id=service_id))
|
|
return redirect(url_for('.choose_service'))
|