mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Adjusted and added static page views logic
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import (render_template, url_for, redirect, request, abort)
|
||||
from flask import (render_template, url_for, redirect, request)
|
||||
from app.main import main
|
||||
from app import convert_to_boolean
|
||||
from app.main.forms import SearchTemplatesForm
|
||||
@@ -7,6 +7,8 @@ from flask_login import (login_required, current_user)
|
||||
from notifications_utils.template import HTMLEmailTemplate
|
||||
from notifications_utils.international_billing_rates import INTERNATIONAL_BILLING_RATES
|
||||
|
||||
from app.main.views.sub_navigation_dictionaries import features_nav
|
||||
|
||||
|
||||
@main.route('/')
|
||||
def index():
|
||||
@@ -54,16 +56,6 @@ def design_content():
|
||||
return render_template('views/design-patterns-content-guidance.html')
|
||||
|
||||
|
||||
@main.route('/information-security')
|
||||
def information_security():
|
||||
return render_template('views/information-security.html')
|
||||
|
||||
|
||||
@main.route('/terms')
|
||||
def terms():
|
||||
return render_template('views/terms-of-use.html')
|
||||
|
||||
|
||||
@main.route('/_email')
|
||||
def email_template():
|
||||
return str(HTMLEmailTemplate({'subject': 'foo', 'content': (
|
||||
@@ -109,34 +101,77 @@ def email_template():
|
||||
|
||||
@main.route('/documentation')
|
||||
def documentation():
|
||||
abort(410)
|
||||
return render_template('views/documentation.html')
|
||||
|
||||
|
||||
@main.route('/integration_testing')
|
||||
@main.route('/integration_testing', endpoint='old_integration_testing')
|
||||
@main.route('/integration-testing')
|
||||
def integration_testing():
|
||||
return render_template('views/integration_testing.html')
|
||||
|
||||
|
||||
@main.route('/roadmap')
|
||||
def roadmap():
|
||||
return render_template('views/roadmap.html')
|
||||
|
||||
|
||||
@main.route('/features')
|
||||
def features():
|
||||
return render_template('views/features.html')
|
||||
|
||||
|
||||
@main.route('/using_notify')
|
||||
def using_notify():
|
||||
return render_template('views/using-notify.html')
|
||||
|
||||
|
||||
@main.route('/information-risk-management')
|
||||
def information_risk_management():
|
||||
return render_template('views/information-risk-management.html')
|
||||
if request.endpoint == "main.old_integration_testing":
|
||||
return redirect(url_for('.integration_testing'), code=301)
|
||||
else:
|
||||
return render_template('views/integration-testing.html')
|
||||
|
||||
|
||||
@main.route('/callbacks')
|
||||
def callbacks():
|
||||
return render_template('views/callbacks.html')
|
||||
|
||||
|
||||
# --- Features --- #
|
||||
|
||||
@main.route('/features')
|
||||
def features():
|
||||
return render_template(
|
||||
'views/features.html',
|
||||
navigation_links=features_nav()
|
||||
)
|
||||
|
||||
|
||||
@main.route('/roadmap', endpoint='old_roadmap')
|
||||
@main.route('/features/roadmap', endpoint='roadmap')
|
||||
def roadmap():
|
||||
if request.endpoint == "main.old_roadmap":
|
||||
return redirect(url_for('.roadmap'), code=301)
|
||||
else:
|
||||
return render_template(
|
||||
'views/roadmap.html',
|
||||
navigation_links=features_nav()
|
||||
)
|
||||
|
||||
|
||||
@main.route('/information-risk-management', endpoint='information_risk_management')
|
||||
@main.route('/features/security', endpoint='security')
|
||||
def security():
|
||||
if request.endpoint == "main.information_risk_management":
|
||||
return redirect(url_for('.security'), code=301)
|
||||
else:
|
||||
return render_template(
|
||||
'views/security.html',
|
||||
navigation_links=features_nav()
|
||||
)
|
||||
|
||||
|
||||
@main.route('/terms', endpoint='old_terms')
|
||||
@main.route('/features/terms', endpoint='terms')
|
||||
def terms():
|
||||
if request.endpoint != "main.terms":
|
||||
return redirect(url_for('.terms'), code=301)
|
||||
else:
|
||||
return render_template(
|
||||
'views/terms-of-use.html',
|
||||
navigation_links=features_nav()
|
||||
)
|
||||
|
||||
|
||||
@main.route('/information-security', endpoint='information_security')
|
||||
@main.route('/using_notify', endpoint='old_using_notify')
|
||||
@main.route('/features/using-notify')
|
||||
def using_notify():
|
||||
if request.endpoint != "main.using_notify":
|
||||
return redirect(url_for('.using_notify'), code=301)
|
||||
else:
|
||||
return render_template(
|
||||
'views/using-notify.html',
|
||||
navigation_links=features_nav()
|
||||
)
|
||||
|
||||
28
app/main/views/sub_navigation_dictionaries.py
Normal file
28
app/main/views/sub_navigation_dictionaries.py
Normal file
@@ -0,0 +1,28 @@
|
||||
def features_nav():
|
||||
return [
|
||||
{
|
||||
"name": "Features",
|
||||
"link": "main.features",
|
||||
},
|
||||
{
|
||||
"name": "Roadmap",
|
||||
"link": "main.roadmap",
|
||||
},
|
||||
{
|
||||
"name": "Security",
|
||||
"link": "main.security",
|
||||
},
|
||||
{
|
||||
"name": "Performance",
|
||||
"link": "https://www.gov.uk/performance/govuk-notify",
|
||||
"external_link": True,
|
||||
},
|
||||
{
|
||||
"name": "Terms of use",
|
||||
"link": "main.terms",
|
||||
},
|
||||
{
|
||||
"name": "Using Notify",
|
||||
"link": "main.using_notify",
|
||||
},
|
||||
]
|
||||
@@ -32,7 +32,7 @@ def test_logged_in_user_redirects_to_choose_service(
|
||||
|
||||
@pytest.mark.parametrize('view', [
|
||||
'cookies', 'using_notify', 'pricing', 'terms', 'integration_testing', 'roadmap',
|
||||
'features', 'information_risk_management', 'callbacks'
|
||||
'features', 'callbacks', 'documentation', 'security'
|
||||
])
|
||||
def test_static_pages(
|
||||
client,
|
||||
@@ -50,7 +50,7 @@ def test_static_pages(
|
||||
('delivery_and_failure', 'messagedeliveryandfailure'),
|
||||
('trial_mode', 'trial-mode'),
|
||||
])
|
||||
def test_old_static_pages(
|
||||
def test_old_static_pages_redirect_to_using_notify_with_anchor(
|
||||
client,
|
||||
view,
|
||||
expected_anchor,
|
||||
@@ -62,3 +62,25 @@ def test_old_static_pages(
|
||||
_anchor=expected_anchor,
|
||||
_external=True
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('view, expected_view', [
|
||||
('information_risk_management', 'security'),
|
||||
('old_integration_testing', 'integration_testing'),
|
||||
('old_roadmap', 'roadmap'),
|
||||
('information_risk_management','security'),
|
||||
('old_terms','terms'),
|
||||
('information_security','using_notify'),
|
||||
('old_using_notify','using_notify'),
|
||||
])
|
||||
def test_old_static_pages_redirect(
|
||||
client,
|
||||
view,
|
||||
expected_view
|
||||
):
|
||||
response = client.get(url_for('main.{}'.format(view)))
|
||||
assert response.status_code == 301
|
||||
assert response.location == url_for(
|
||||
'main.{}'.format(expected_view),
|
||||
_external=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user