Ben Thorner 21452649fd Fix ignoring submitted data that was falsey
This was causing some tests for the "estimate_volume" endpoint to
fail due to the surprising way that form handles "''":

- The form is the exclusive user of the ForgivingIntegerField [^1].
- The field secretly/silently converts "''" to the integer 0 [^2].

If the validations fail, we don't want to surprise the user with a
"0" when they didn't enter one. The field already handles this by
massaging the values in the __call__ method that generates the HTML
for the form [^3]. However, there are two scenarios:

- User submits field with '' - converted to integer 0.
- User submits field with '0' - remains as a string.

In the case where "value" is "''", the parent class will use the
converted value from form.data instead [^4]. This seems to be an
oversight and so we get either the integer 0 (from form.data) or
the string '0' (from the value kwarg). Complicado!

Previously it was a fluke that we avoided replaying the integer 0
to the user; the previous commit removes the fluke. This fixes the
conditional to always use the data in the "value" kwarg if it has
been provided, as it's meant to override "form.data".

[^1]: 9f63449384
[^2]: a22b8cf684/app/main/forms.py (L364)
[^3]: a22b8cf684/app/main/forms.py (L393)
[^4]: a22b8cf684 (diff-a1c8d24b22d4478fe71f75fd43b71b18dd82aae97bc63de84473a6da1902909bR215)
2022-03-07 12:55:38 +00:00
2022-02-04 10:43:36 +00:00
2022-02-04 10:43:36 +00:00

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.9 in production.

NPM packages

brew install node

NPM is Node's package management tool. n is a tool for managing different versions of Node. The following installs n and uses the long term support (LTS) version of Node.

npm install -g n
n lts

environment.sh

In the root directory of the application, run:

echo "
export NOTIFY_ENVIRONMENT='development'
export FLASK_APP=application.py
export FLASK_ENV=development
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.

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 code, run npm run watch to achieve the same.

To test the application

# install dependencies, etc.
make bootstrap

# run all the tests
make test

# continuously run js tests
npm run test-watch

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

Further docs

Description
The UI of Notify.gov
Readme 545 MiB
Languages
Python 69.3%
HTML 16.6%
JavaScript 11.1%
SCSS 0.9%
Nunjucks 0.7%
Other 1.4%