mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 19:58:24 -04:00
Replace Current service with chosen service name.
This commit is contained in:
@@ -17,6 +17,7 @@ def add_service():
|
|||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
user = users_dao.get_user_by_id(session['user_id'])
|
user = users_dao.get_user_by_id(session['user_id'])
|
||||||
service_id = services_dao.insert_new_service(form.name.data, user.id)
|
service_id = services_dao.insert_new_service(form.name.data, user.id)
|
||||||
|
session['service_name'] = form.name.data
|
||||||
return redirect(url_for('main.service_dashboard', service_id=service_id))
|
return redirect(url_for('main.service_dashboard', service_id=service_id))
|
||||||
else:
|
else:
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from flask import (render_template, redirect, url_for)
|
from flask import (render_template, redirect, url_for, session)
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from app.main.dao import services_dao
|
from app.main.dao import services_dao
|
||||||
from app.main import main
|
from app.main import main
|
||||||
@@ -11,6 +11,7 @@ def choose_service():
|
|||||||
# If there is only one service redirect
|
# If there is only one service redirect
|
||||||
# to the service dashboard.
|
# to the service dashboard.
|
||||||
if len(services['data']) == 1:
|
if len(services['data']) == 1:
|
||||||
|
session['service_name'] = services['data'][0]['name']
|
||||||
return redirect(url_for(
|
return redirect(url_for(
|
||||||
'main.service_dashboard', service_id=services['data'][0]['id']))
|
'main.service_dashboard', service_id=services['data'][0]['id']))
|
||||||
return render_template(
|
return render_template(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from flask import (abort, render_template)
|
from flask import (abort, render_template, session)
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
from app.main import main
|
from app.main import main
|
||||||
from app.main.dao.services_dao import get_service_by_id
|
from app.main.dao.services_dao import get_service_by_id
|
||||||
@@ -11,6 +11,7 @@ from ._jobs import jobs
|
|||||||
def service_dashboard(service_id):
|
def service_dashboard(service_id):
|
||||||
try:
|
try:
|
||||||
service = get_service_by_id(service_id)
|
service = get_service_by_id(service_id)
|
||||||
|
session['service_name'] = service['data']['name']
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
if e.status_code == 404:
|
if e.status_code == 404:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ def two_factor():
|
|||||||
login_user(user)
|
login_user(user)
|
||||||
finally:
|
finally:
|
||||||
del session['user_details']
|
del session['user_details']
|
||||||
return redirect(url_for('.choose_service'))
|
return redirect(url_for('main.choose_service'))
|
||||||
|
|
||||||
return render_template('views/two-factor.html', form=form)
|
return render_template('views/two-factor.html', form=form)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<div class="column-half">
|
<div class="column-half">
|
||||||
<details class="dropdown">
|
<details class="dropdown">
|
||||||
<summary class="dropdown-toggle">
|
<summary class="dropdown-toggle">
|
||||||
Current service
|
{{ session['service_name'] }}
|
||||||
</summary>
|
</summary>
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ url_for('main.choose_service') }}">Switch service</a>
|
<a href="{{ url_for('main.choose_service') }}">Switch service</a>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from flask import url_for
|
from flask import url_for, session
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_recent_jobs_on_dashboard(app_,
|
def test_should_show_recent_jobs_on_dashboard(app_,
|
||||||
@@ -14,4 +14,6 @@ def test_should_show_recent_jobs_on_dashboard(app_,
|
|||||||
response = client.get(url_for('main.service_dashboard', service_id=123))
|
response = client.get(url_for('main.service_dashboard', service_id=123))
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert 'You haven’t sent any text messages yet' in response.get_data(as_text=True)
|
text = response.get_data(as_text=True)
|
||||||
|
assert 'You haven’t sent any text messages yet' in text
|
||||||
|
assert 'Test Service' in text
|
||||||
|
|||||||
Reference in New Issue
Block a user