From 43a27676cbf27605aa1c9c446c047220d5a53fae Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 16 Oct 2020 09:30:54 +0100 Subject: [PATCH 1/2] Remove the styleguide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The idea was that this would be a place to document all the design patterns used in Notify. However it hasn’t been kept up to date, and, looking at the `git blame`[1] no new patterns have been added for 5 years. I think it’s better to get rid of it than have to keep maintaining something which is inaccurate. 1. https://github.com/alphagov/notifications-admin/blame/64aa0d359c029dddc49f82491756a7a61bd22ded/app/templates/views/styleguide.html --- app/main/__init__.py | 1 - app/main/views/styleguide.py | 40 ----- app/navigation.py | 4 - app/templates/views/styleguide.html | 213 ------------------------ tests/app/main/views/test_styleguide.py | 4 - 5 files changed, 262 deletions(-) delete mode 100644 app/main/views/styleguide.py delete mode 100644 app/templates/views/styleguide.html delete mode 100644 tests/app/main/views/test_styleguide.py diff --git a/app/main/__init__.py b/app/main/__init__.py index 0521895d6..d5620b705 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -35,7 +35,6 @@ from app.main.views import ( # noqa isort:skip service_settings, sign_in, sign_out, - styleguide, templates, two_factor, tour, diff --git a/app/main/views/styleguide.py b/app/main/views/styleguide.py deleted file mode 100644 index c8bc29cc4..000000000 --- a/app/main/views/styleguide.py +++ /dev/null @@ -1,40 +0,0 @@ -from flask import abort, current_app, render_template -from flask_wtf import FlaskForm as Form -from notifications_utils.template import SMSPreviewTemplate -from wtforms import ( - FileField, - PasswordField, - StringField, - TextAreaField, - validators, -) - -from app.main import main - - -@main.route('/_styleguide') -def styleguide(): - - if not current_app.config['SHOW_STYLEGUIDE']: - abort(404) - - class FormExamples(Form): - username = StringField(u'Username') - password = PasswordField(u'Password', [validators.required()]) - code = StringField('Enter code') - message = TextAreaField(u'Message') - file_upload = FileField('Upload a CSV file to add your recipients’ details') - - sms = "Your vehicle tax for ((registration number)) is due on ((date)). Renew online at www.gov.uk/vehicle-tax" - - form = FormExamples() - form.message.data = sms - form.validate() - - template = SMSPreviewTemplate({'content': sms, 'template_type': 'sms'}) - - return render_template( - 'views/styleguide.html', - form=form, - template=template - ) diff --git a/app/navigation.py b/app/navigation.py index a7fc488a5..bce698bec 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -321,7 +321,6 @@ class HeaderNavigation(Navigation): 'show_accounts_or_dashboard', 'sign_out', 'start_job', - 'styleguide', 'submit_request_to_go_live', 'template_history', 'template_usage', @@ -666,7 +665,6 @@ class MainNavigation(Navigation): 'sign_in', 'sign_out', 'start_job', - 'styleguide', 'support', 'support_public', 'suspend_service', @@ -978,7 +976,6 @@ class CaseworkNavigation(Navigation): 'sign_in', 'sign_out', 'start_job', - 'styleguide', 'submit_request_to_go_live', 'support', 'support_public', @@ -1291,7 +1288,6 @@ class OrgNavigation(Navigation): 'sign_in', 'sign_out', 'start_job', - 'styleguide', 'submit_request_to_go_live', 'support', 'support_public', diff --git a/app/templates/views/styleguide.html b/app/templates/views/styleguide.html deleted file mode 100644 index 9b19d8b22..000000000 --- a/app/templates/views/styleguide.html +++ /dev/null @@ -1,213 +0,0 @@ -{% extends "withoutnav_template.html" %} - -{% from "components/banner.html" import banner %} -{% from "components/big-number.html" import big_number %} -{% from "components/browse-list.html" import browse_list %} -{% from "components/page-footer.html" import page_footer %} -{% from "components/table.html" import mapping_table, list_table, row, field, text_field, boolean_field, right_aligned_field_heading %} -{% from "components/textbox.html" import textbox %} -{% from "components/file-upload.html" import file_upload %} -{% from "components/api-key.html" import api_key %} - -{% block per_page_title %} - Styleguide -{% endblock %} - -{% block maincolumn_content %} - -

- www.notify.works/_styleguide -

- -

- View source -

- -

Banner

-
-
-

Used to show the status of a thing or action.

- - {{ banner("You sent 1,234 text messages", with_tick=True) }} - - {{ banner('You’re not allowed to do this', 'dangerous')}} - - {{ banner('Are you sure you want to delete?', 'dangerous', delete_button="Yes, delete this thing")}} - -
-
- - -

Big number

- -

Used to show some important statistics.

- -
-
- {{ big_number("567") }} -
-
- {{ big_number("2", "Messages delivered") }} -
-
- -

Browse list

- -

Used to navigate to child pages.

- - {{ browse_list([ - { - 'title': 'Change your username', - 'link': 'http://example.com', - }, - { - 'title': 'Change your password', - 'link': 'http://example.com', - 'hint': 'Your password is used to log in' - }, - { - 'title': 'Delete everything', - 'link': 'http://example.com', - 'hint': 'You cannot undo this', - 'destructive': True - } - ]) }} - -

Page footer

- -

- Used to submit forms and optionally provide a link to go back to the - previous page. -

-

- Must be used inside a form. -

-

- Adds a hidden CSRF token to the page. -

- - {{ page_footer( - button_text='Continue' - ) }} - - {{ page_footer( - button_text='Save', - delete_link='http://example.com', - delete_link_text='delete this thing' - )}} - - {{ page_footer( - button_text='Delete', destructive=True - ) }} - - {{ page_footer( - button_text='Send' - ) }} - - {{ page_footer( - button_text='Sign in', secondary_link='http://example.com', secondary_link_text="I’ve forgotten my password" - ) }} - -

Tables

-
-
-

- Used for comparing rows of data. -

- {% call mapping_table( - caption='Account settings', - field_headings=['Label', 'True', 'False', 'Action'], - field_headings_visible=False, - caption_visible=True - ) %} - {% call row() %} - {{ text_field('Username' )}} - {{ boolean_field(True) }} - {{ boolean_field(False) }} - {% call field(align='right') %} - Change - {% endcall %} - {% endcall %} - {% endcall %} - - {% call(item, row_number) list_table( - [ - { - 'file': 'dispatch_20151114.csv', 'status': 'Queued' - }, - { - 'file': 'dispatch_20151117.csv', 'status': 'Delivered' - }, - { - 'file': 'remdinder_monday.csv', 'status': 'Failed' - } - ], - caption='Messages', - field_headings=['File', right_aligned_field_heading('Status')], - field_headings_visible=True, - caption_visible=False - ) %} - {% call field() %} - {{ item.file }} - {% endcall %} - {% call field( - align='right', - status='error' if item.status == 'Failed' else 'default' - ) %} - {{ item.status }} - {% endcall %} - {% endcall %} - - {% call(item, row_number) list_table( - [], - caption='Jobs', - field_headings=['Job', 'Time'], - caption_visible=True, - empty_message='You have not scheduled any jobs yet' - ) %} - {% call field() %} - {{ item.job }} - {% endcall %} - {% call field() %} - {{ item.time }} - {% endcall %} - {% endcall %} - -
-
- -

Textbox

- {{ textbox(form.username) }} - {{ textbox(form.password) }} - {{ textbox(form.message, highlight_placeholders=True) }} - {{ textbox(form.code, width='1-8') }} - -

File upload

- {{ file_upload(form.file_upload) }} - -

API key

- - {{ api_key('00000000-0000-0000-0000-000000000000') }} - - -

Formatted list

- -

- {{ 'A' | formatted_list(prefix="one item called") }} -

- -

- {{ 'AB' | formatted_list(prefix_plural="two items called") }} -

- -

- {{ 'ABC' | formatted_list }} -

- -

- {{ 'ABCD' | formatted_list(before_each='', after_each='', conjunction='or') }} -

- -{% endblock %} diff --git a/tests/app/main/views/test_styleguide.py b/tests/app/main/views/test_styleguide.py deleted file mode 100644 index cacac12dd..000000000 --- a/tests/app/main/views/test_styleguide.py +++ /dev/null @@ -1,4 +0,0 @@ -def test_styleguide_can_render(app_): - response = app_.test_client().get('/_styleguide') - - assert response.status_code == 200 From 13b63e1a243da96e76a8436188a963c655710e04 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 16 Oct 2020 10:29:26 +0100 Subject: [PATCH 2/2] Remove reference to styleguide from config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The styleguide no longer exists, so this variable isn’t referred to from anywhere. --- app/config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/config.py b/app/config.py index 9dc29106f..aa3ecb4e7 100644 --- a/app/config.py +++ b/app/config.py @@ -59,7 +59,6 @@ class Config(object): # updated unless the session is changed - but it's generally refreshed by `save_service_or_org_after_request` # every time anyway, except for specific endpoints (png/pdfs generally) where we've disabled that handler. SESSION_REFRESH_EACH_REQUEST = False - SHOW_STYLEGUIDE = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None CSV_UPLOAD_BUCKET_NAME = 'local-notifications-csv-upload' @@ -152,7 +151,6 @@ class Preview(Config): class Staging(Config): - SHOW_STYLEGUIDE = False HTTP_PROTOCOL = 'https' HEADER_COLOUR = '#6F72AF' # $mauve CSV_UPLOAD_BUCKET_NAME = 'staging-notifications-csv-upload' @@ -167,7 +165,6 @@ class Staging(Config): class Live(Config): - SHOW_STYLEGUIDE = False HEADER_COLOUR = '#005EA5' # $govuk-blue HTTP_PROTOCOL = 'https' CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'