2020-05-16 16:00:38 -07:00
2019-04-12 15:36:57 +01:00
2020-02-24 17:28:29 +00:00
2019-11-29 15:25:37 +00:00
2019-03-25 11:14:05 +00:00
2019-11-29 15:25:37 +00:00
2020-04-29 22:56:45 +00:00
2020-03-06 13:25:53 +00:00
2020-05-15 15:37:35 +01:00
2020-05-15 15:37:35 +01:00
2020-01-21 15:10:43 +00:00
2019-11-29 15:25:37 +00:00

notifications-admin

GOV.UK Notify admin application.

Features of this application

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

First-time setup

1. Install Homebrew

Brew is a package manager for OSX. The following command installs brew:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This command changes occasionally. You can find the most recent command at Homebrew

2. Make Sure You're Using Correct Language Versions

Languages needed

  • Python 3.6.x
  • Node 10.15.3 or greater
  • npm 6.4.1 or greater

Need to get node? Run:

    brew install node

2.1. n For Node Version Management

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

2.2. nvm For Node Version Management

NVM is also a popular tool for node verison managmement. Install it with Homebrew (instructions can be found with a simple Google search), and make sure you have a Node version installed higher than 10.15.3, and use it. I have arbitrarily chosen version 12.16.2 for this example.

    nvm use 12.16.2

3. Install NPM Dependencies

    npm install
    npm rebuild node-sass

4. Install virtualenvwrapper

You'll need the pip package virtualenvwrapper installed. Installation is pretty easy; run this command for the 3.6.x version of Python you're using for this project:

    pip install virtualenvwrapper

...However, you'll need to configure it to run in your bash terminal. Add the following lines to your ~/.bash_profile if you're using pyenv to manage your python versions:

Note: Python version 3.6.3 is the 3.6.x version arbitrarily chosen for this example.

    export WORKON_HOME=~/virtualenvs
    export VIRTUALENVWRAPPER_HOOK_DIR=$WORKON_HOME/hooks
    source ~/.pyenv/versions/3.6.3/bin/virtualenvwrapper.sh

If no ~/virtualenvs directory exists, make one.

If you're using the main system Python version on an OSX machine, your final ~/.bash_profile line will look more like this:

    source /usr/local/bin/virtualenvwrapper.sh

Please see the virtualenvwrapper website for more installation and configuration info. This step gives you access to mkvirtualenv on the command line.

5. Setup Virtual Environment

The app runs within a virtual environment. We use mkvirtualenv for easier working with venvs

Using Your Machine's System Python:

    mkvirtualenv -p /usr/local/bin/python3 notifications-admin

Using pyenv:

Note: Python version 3.6.3 is the 3.6.x version arbitrarily chosen for this example.

mkvirtualenv -p ~/.pyenv/versions/3.6.3/bin/python notifications-admin

6. Install Python Dependencies

Install dependencies and build the frontend assets:

    workon notifications-admin
    ./scripts/bootstrap.sh

Note: You may need versions of both Python 3 and Python 2 accessible to build the python dependencies. pyenv is great for that, and making both Python versions accessible can be done like so:

    pyenv global 3.6.3 2.7.15

7. Rebuilding the frontend assets

If you want the front end assets to re-compile on changes, leave this running in a separate terminal from the app

    npm run watch

8. Create a local environment.sh file containing the following:

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

9. AWS credentials

Your aws credentials should be stored in a folder located at ~/.aws. Follow Amazon's instructions for storing them correctly

10. Running the application

In the root directory of the application, run:

    workon notifications-admin
    ./scripts/run_app.sh

Then visit localhost:6012

Updating application dependencies

requirements.txt file is generated from the requirements-app.txt in order to pin versions of all nested dependencies. If requirements-app.txt has been changed (or we want to update the unpinned nested dependencies) requirements.txt should be regenerated with

make freeze-requirements

requirements.txt should be committed alongside requirements-app.txt changes.

Working with static assets

When running locally static assets are served by Flask at http://localhost:6012/static/…

When running on preview, staging and production theres a bit more to it:

notify-static-after

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