Giter Club home page Giter Club logo

notifications-admin's Introduction

notifications-admin

GOV.UK Notify admin application - https://www.notifications.service.gov.uk/

  • Register and manage users
  • Create and manage services
  • Send batch emails and SMS by uploading a CSV
  • Show history of notifications

Setting up

Python version

At the moment we run Python 3.11 in production.

NodeJS & NPM

If you don't have NodeJS on your system, install it with homebrew.

brew install node

nvm is a tool for managing different versions of NodeJS. Follow the guidance on nvm's github repository to install it.

Once installed, run the following to switch to the version of NodeJS for this project. If you don't have that version, it should tell you how to install it.

nvm use

environment.sh

In the root directory of the application, run:

echo "
export NOTIFY_ENVIRONMENT='development'
export FLASK_APP=application.py
export FLASK_DEBUG=1
export WERKZEUG_DEBUG_PIN=off
"> environment.sh

AWS credentials

To run parts of the app, such as uploading letters, you will need appropriate AWS credentials. See the Wiki for more details.

Pre-commit

We use pre-commit to ensure that committed code meets basic standards for formatting, and will make basic fixes for you to save time and aggravation.

Install pre-commit system-wide with, eg brew install pre-commit. Then, install the hooks in this repository with pre-commit install --install-hooks.

To run the application

# install dependencies, etc.
make bootstrap

# run the web app
make run-flask

Then visit localhost:6012.

Any Python code changes you make should be picked up automatically in development. If you're developing JavaScript or CSS code, run make watch-frontend to achieve the same.

To test the application

# install dependencies, etc.
make bootstrap

# run all the tests
make test

# run the js tests
npx jest

# run a single js test
npx jest <pathToAJavascriptTestfile>

# continuously run js tests
npm run test-watch

# debug a js test in chrome
npm run debug --test=[name of test file]

To run a specific JavaScript test, you'll need to copy the full command from package.json.

Further docs

notifications-admin's People

Contributors

allait avatar antimega avatar ashimali avatar bandesz avatar benthorner avatar blesseddev avatar catherineheywood avatar crystalpea avatar dependabot[bot] avatar gov-cjwaszczuk avatar idavidmcdonald avatar imdadahad avatar karlchillmaid avatar kentsanggds avatar klssmith avatar kr8n3r avatar leohemsted avatar lolylena avatar mannickutd avatar minglis avatar pyup-bot avatar quis avatar risicle avatar saimaghafoor avatar sakisv avatar samuelhwilliams avatar servingupaces avatar tombye avatar venusbb avatar whpearson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notifications-admin's Issues

Alert banner `govukButton` display with raw HTML contents

Hi,

There are some issues in the alert banner when a user wants to delete the templates.

image

{{ govukButton({
"text": "" if thing else delete_button,
"html": delete_button + "<span class=\"govuk-visually-hidden\"> ‘" + thing + "’</span>" if thing else "",
"name": "delete",
"classes": "govuk-button--warning govuk-!-margin-top-2",
}) }}

The default element will be button, but we use HTML code as button value. Therefore, the button will show all the raw codes as text on the button.

We could remove the HTML code to revise the problem:

 {{ govukButton({
   "text": "" if thing else delete_button,
   "html": delete_button + " ‘" + thing + "’" if thing else "", 
   "name": "delete", 
   "classes": "govuk-button--warning govuk-!-margin-top-2", 
 }) }} 

image

Thanks~

Previewing and validating recipient CSVs uploads is inconsistent

Pain

Relates to: alphagov/notifications-utils#936

There are two scenarios where a user uploads a CSV of recipients:

Both make an instance of RecipientCSV and render something to show some or none of the CSV and its associated errors.

List of all CSV checks
Check used in "send" templates used in "contact-list" templates notes
too many rows column-errors column-errors recipients.too_many_rows
not allowed to send to column-errors column-errors not recipients.allowed_to_send_to
no rows column-errors too-many-columns "send" uses count_of_recipients, "contact-list" uses Jinja filter
missing header row column-errors too-many-columns "send" uses recipients.missing_column_headers, "contact-list" uses | length == 1
too many columns too-many-columns "contact-list" checks if > 1
bad column names column-errors column-errors "send" uses recipients.has_recipient_columns, "contact-list" uses | length == 1
duplicate recipient columns column-errors "send" uses recipients.duplicate_recipient_column_headers, "contact-list" glosses over it (see "too many columns")
missing columns column-errors, row-errors row-errors both use recipients.missing_column_headers
sent previously sent-previously
letters in trial mode trying-to-send-letters-in-trial-mode
too many messages too-many-messages "send" uses recipients.more_rows_than_can_send
message empty row-errors row-errors "send" is meant to use custom text if there are multiple errors but this doesn't seem to work, otherwise both say "Missing"
message too long row-errors "send" uses item.message_too_long
address errors row-errors "send" uses item.as_postal_address.*
other cell errors row-errors row-errors both print the error verbatim for each column

Any major changes to RecipientCSV need to be reflected in both places, but they are inconsistent and confusing:

  1. Some of the errors don't correspond to the template name e.g.

  2. "send" does different checks to "contact-list" e.g.

  3. The set of templates is different between "send" and "contact-list":

    • "contact-list" has column-errors, row-errors, too-many-columns.
    • "send" has column-errors, rows-errors, and 7 error-specific partials.
  4. The views check for errors in different places and levels of abstraction:

Cure (ideas)

In reality, there are three kinds of error we need to handle:

  1. Top-level errors e.g. not enough columns, too many rows.

  2. Row-wide errors e.g. address issues (since the address spans multiple columns).

  3. Cell-specific errors e.g. invalid phone number.

We could consolidate the preview / validation of a RecipientCSV into a single template / partial hierarchy, so that it can be reused consistently. This would likely correspond to a common set of helper functions.

Some of the checks might be specific to one use case e.g. "letters in trial mode". This kind of check should be done and displayed separately, as it's not relevant to the processing of the CSV.

Email regex incorrectly matches on pipe literal.

Hello,

Your email regex for validating domains matches the domain preceded by an @, a full-stop . or (mistakenly I believe) the pipe character, |.

When evaluated, the following code prints "true".

import re
email_regex = (r"[\.|@]({})$".format("|".join(["gov.uk","mod.uk"])))
print bool(re.search(email_regex, "[email protected]|gov.uk"))

That code is the code from app/utils.py lines 258,259 with the allowed domains list expanded with the examples here and an email address filled in.

I don't know how the pipe character would be handled in the case of trying to email [email protected]|gov.uk, or whether it would get through other validation but could lead to potential vulnerability if for example the pipe and anything after it were to be discarded.

I believe the regex intended was r"(?:[\.]|[@])({})$".format(...) which matches one of @ or . followed by an allowed domain. (with a non-capturing group here to preserve the previous group numbers although they aren't used anyway).

Need to create a .babelrc file for gulp to run

Trying to build the frontend for the first time I ran into this problem:

[15:12:55] Requiring external module babel-core/register
/Users/andyw/Repositories/alphagov/notifications-admin/gulpfile.babel.js:24
gulp.task('copy:govuk_template:template', () => gulp.src('bower_components/gov
                                           ^
SyntaxError: Unexpected token )

Which is obviously gulp choking on the ES6 syntax. To fix it I added a .babelrc file as suggested here:

{
  "presets": ["es2015"]
}

You should probably add a note about this to the README or commit the file so that others don't get tripped up.

Copying API key to clipboard puts a space on either end

As title; extra spaces when copying API keys! This stops them working when pasted, obviously :)

  1. Create an API key
  2. Copy said API key to clipboard using the button
  3. Paste API key somewhere else, observe leading and trailing spaces

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.