Skip to main content

Money to Prisoners Common

A Django app containing utilities and assets common to all Prisoner Money applications. This version is only tested with Django 5.2.

https://github.com/ministryofjustice/money-to-prisoners-common/actions/workflows/test.yml/badge.svg

How this library fits into the wider service — architecture, data flows, deployment and support — is documented in money-to-prisoners-deploy.

Features

  • Build pipeline CLI with actions that can depend on others (inspired by invoke/fabric)

  • Base SCSS, JS and static assets

  • Base templates for staff and public apps

  • Build action to include GOV.UK Design System assets

  • Reusable templates for form fields and errors

  • Authentication utilities and views for connecting to money-to-prisoners-api

  • User account management forms and views

  • REST utilities for communicating with money-to-prisoners-api

  • Utility for communicating with HMPPS Prison API (NOMIS)

  • Integration and accessibility testing with selenium

  • Python code style testing

  • Log formatting for shipping to ELK

  • Cookie management tools to anonymise users and allow them to opt in

  • Prometheus metrics view providing app version information

  • Constants shared between apps

  • Email sending using GOV.UK Notify

Usage

This is not a standalone Django application and is included as a requirement of Prisoner Money apps.

  • Make code changes and add any tests necessary

  • Test using ./run.py test or python setup.py test

  • Bump the package version with ./run.py bump_version [--major | --minor | --patch]

  • Submit to PyPi by:

    • making a new release on Github (package version comes from the code, not Github release title)

    • or ./run.py upload locally (if release cannot be made on Github for some reason)

Add or update money-to-prisoners-common~=<major version>.<minor version>.0 to the app’s requirements base.txt. There is an additional variant installed as a setuptools extra: Use money-to-prisoners-common[testing]~=<major version>.<minor version>.0 for environments requiring testing; this is placed into the app’s requirements dev.txt. Incrementing the build/patch version is used to push minor fixes so these above requirements will automatically include them.

While making changes to this library, you can install it locally in “editable” mode. See python_dependencies --common-path … build task.

Translating

Update translation files with ./run.py make_messages – you need to do this every time any translatable text is updated.

Compile messages ./run.py compile_messages – only needed during local testing or development, it happens automatically during build or upload.

Requires [transifex cli tool](https://github.com/transifex/cli#installation) for synchronisation:

Pull updates from Transifex with ./run.py translations --pull. You’ll need to update translation files afterwards and manually check that the merges occurred correctly.

Push latest English to Transifex with ./run.py translations --push. NB: you should pull updates before pushing to merge correctly.

Assets

All shared assets used by Prisoner Money apps are kept in this package. Each app’s build scripts install this package automatically which also bring in the GOV.UK Design System.

Assets that need compiling are in mtp_common/assets-src/mtp_common. Static assets are in mtp_common/static/mtp_common.

Common templates used by the client apps are kept in mtp_common/templates/(govuk-frontend|mtp_common). The ones in govuk-frontend are essentially translated from the GOV.UK Design System whereas those in mtp_common are custom components or are heavily modified.

Local Development Environment

Prisoner Money apps can be run natively (i.e. directly by python on your machine) or using docker-compose. Using docker-compose is perhaps the easiest way to bring up all Prisoner Money apps in concert, and needs no credentials of any kind. However, when editing this common library, it’s easier to run them natively because this package can be installed in “editable” mode.

To work on a single app you do not need anything below: each app repository has its own docker-compose.yml that runs it with the database, the API and the other apps from their published images. See the getting-started guide, which also lists the local addresses and test logins.

Check out each app and helper repository side-by-side in one directory using git:

Running natively (does not require access to the private deploy repository)

Each app describes its own installation in its read-me file, but here’s a quick guide:

  1. Setup local postgres database server. There’s no need to create a user or database if using default settings.

  2. Install python version 3.12.

  3. Install nodejs version 24.

  4. Setup a python virtual environment for each app. These are used to isolate python dependency libraries for each app.

    1. You can either make one directly in each repository directory:

    python3 -m venv venv
    1. Or install and use virtualenvwrapper which allows activating a virtual environment by name from any location. This option is particularly helpful for git hooks or when you normally run the apps in docker-compose. In the directory containing all repos:

    for app in api cashbook bank-admin noms-ops emails transaction-uploader send-money start-page deploy; do
      cd money-to-prisoners-$app
      mkvirtualenv -a . money-to-prisoners-$app
      [[ -f requirements/dev.txt ]] && pip install -r requirements/dev.txt
      [[ -f requirements.txt ]] && pip install -r requirements.txt
      cd -
    done
    cd money-to-prisoners-common
    mkvirtualenv -a . money-to-prisoners-common
    pip install -e '.[testing]'
  5. Run the apps. The api always needs to be running when any of the other apps are used other than start-page.

    cd <app repository root>
    # activate the virtual environment if one was made directly
    . venv/bin/activate
    # OR activate the virtual environment using virtualenvwrapper
    workon money-to-prisoners-<app name>
    
    # run the app
    ./run.py serve
    # OR if it’s the api, this automatically alternative also creates a fresh database with sample data
    ./run.py start --test-mode

After this has been done once, bringing up apps again only requires repeating step 5.

Running using docker-compose

App images are published as public packages at ghcr.io/ministryofjustice/money-to-prisoners-*, so no credentials, AWS access or registry login are needed – docker pulls them anonymously.

NB: docker-compose builds each app from its own checkout, so all the app repositories above must be cloned side-by-side in one directory first. It is not enough to clone this repository alone.

Your own settings/local.py in any app is deliberately ignored inside the containers – see docker/no-local-settings.py for why. Overrides for the containers belong in docker-compose.yml.

  1. Launch all apps in concert. In this repo:

docker-compose up

 NB: The newer ``docker compose up`` form only works after the ``docker-compose up`` has already built the containers the first time!
  1. Create standard users and populate database with sample data. In this repo:

docker-compose exec api ./manage.py load_test_data

After this has been done once, bringing up the full stack in future only requires running docker-compose up or docker compose up in this repo. Deleting docker images, containers or volumes will require repeating both steps.

If you run into issues with the dockerised development environment, the following troubleshooting steps should reset the state:

  • Shutdown existing docker-compose containers, and remove volumes/networks/images with docker-compose down -v --rmi all from this repo’s root directory (note this will wipe your local database, omit the -v to prevent this)

  • Pull fresh app images via docker-compose pull from this repo’s root directory

  • Rebuild the app images without cache via docker-compose build --no-cache from this repo’s root directory

  • Restart the apps in the background via docker-compose up -d from this repo’s root directory

  • Tail the logs at your leisure via docker-compose logs <app> from money-to-prisoners-common root directory

Accessing the apps

Apps exposing a web interface are accessible at the addresses below. The 300x addresses go through browser-sync, which reloads the page as you make changes; it runs with ./run.py serve, which is also what docker-compose uses. With ./run.py start use the 800x address instead.

Test logins are listed in the getting-started guide.

Caveat: You can only log into one app at a time locally because the cookies within which the session is stored are namespaced to domain only.

Parity testing

See PARITY.md for how to run the whole local stack (Docker Compose, secrets, Playwright suite) against the fixed, reproducible parity data set, and how to deploy a branch to the real parity environment. See money-to-prisoners-api’s PARITY.md for how that fixture data set itself is structured and how to add more of it.

Additional Bespoke Packages

There are several dependencies of the money-to-prisoners-common python library which are maintained by this team, so they may require code-changes when the dependencies (e.g. Django) of the money-to-prisoners-common python library, or any of the Prisoner Money apps, are incremented.

There are additional bespoke dependencies defined as python dependencies within the Prisoner Money apps.

Release files for money-to-prisoners-common 21.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for money-to-prisoners-common 21.2.8
File Size Uploaded
money_to_prisoners_common-21.2.8.tar.gz 253.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for money-to-prisoners-common 21.2.8
File Interpreter ABI Platform
money_to_prisoners_common-21.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 586.1 kB

Release files / money_to_prisoners_common-21.2.8.tar.gz

Download URL money_to_prisoners_common-21.2.8.tar.gz
Size 253.7 kB
Tags Source
SHA-256 checksum
How to use checksums
61c3fb3200dce0fbb8a5b1a27f53184888b12888d00bb5829637393f8751997b
BLAKE2b-256 checksum
How to use checksums
06eaa905b32602f685cf833579031b03418d032d54de7447afae52aba27f69cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / money_to_prisoners_common-21.2.8-py3-none-any.whl

Download URL money_to_prisoners_common-21.2.8-py3-none-any.whl
Size 332.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c679cc442726514f477526cd21bfc4e008af489cbd966c9b8f17807bf5226786
BLAKE2b-256 checksum
How to use checksums
2cfd9c0aa5cae477625494f1bb0d1d6275f6bd8688ca0f3e5742b8378a22438e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

21.2.8 This release

2 release files

21.2.5

2 release files

21.2.4

2 release files

21.2.1

2 release files

21.1.0

2 release files

21.0.0

2 release files

20.1.0

2 release files

19.0.2

2 release files

19.0.1

2 release files

19.0.0

2 release files

18.0.0

2 release files

16.8.0

2 release files

16.6.1

2 release files

16.6.0

2 release files

16.4.0

2 release files

16.2.0

2 release files

16.1.1

2 release files

15.1.0

2 release files

15.0.0

2 release files

14.3.1

2 release files

14.2.0

2 release files

13.5.0

2 release files

13.4.0

2 release files

13.3.0

2 release files

13.2.0

2 release files

13.0.2

2 release files

13.0.1

2 release files

13.0.0

2 release files

12.3.0

2 release files

12.2.0

2 release files

12.1.0

2 release files

12.0.1

2 release files

12.0.0

2 release files

11.4.1

2 release files

11.3.1

2 release files

11.3.0

2 release files

11.2.0

2 release files

11.0.0

2 release files

10.1.0

2 release files

9.20.0

1 release file

9.19.1

2 release files

9.15.3

2 release files

9.15.2

2 release files

9.14.1

2 release files

9.13.0

2 release files

9.12.3

2 release files

9.12.2

2 release files

9.11.2

2 release files

9.11.1

2 release files

9.11.0

2 release files

9.9.0

2 release files

9.8.1

2 release files

9.7.0

2 release files

9.6.1

2 release files

9.6.0

2 release files

9.5.1

2 release files

9.5.0

2 release files

9.4.2

2 release files

9.4.1

2 release files

9.4.0

2 release files

9.3.1

2 release files

9.2.0

2 release files

9.1.0

2 release files

9.0.1

2 release files

8.9.0

2 release files

8.8.0

2 release files

8.7.0

2 release files

8.6.0

2 release files

8.5.1

2 release files

8.5.0

2 release files

8.4.0

2 release files

8.3.2

2 release files

8.2.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.9.1

2 release files

7.9.0

2 release files

7.8.0

2 release files

7.7.0

2 release files

7.6.1

2 release files

7.5.0

2 release files

7.4.0

2 release files

7.3.2

2 release files

7.3.1

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.8.1

2 release files

6.7.0

2 release files

6.6.1

2 release files

6.5.2

2 release files

6.4.0

2 release files

6.3.3

2 release files

6.2.1

2 release files

6.1.1

2 release files

6.0.0

2 release files

5.31.0

2 release files

5.30.0

2 release files

5.29.0

2 release files

5.28.0

2 release files

5.27.0

2 release files

5.26.0

2 release files

5.22.0

2 release files

5.21.0

2 release files

5.18.1

2 release files

5.17.0

2 release files

5.16.0

2 release files

5.15.0

2 release files

5.14.1

2 release files

5.14.0

2 release files

5.13.0

2 release files

5.12.0

2 release files

5.10.0

2 release files

5.9.3

2 release files

5.9.2

2 release files

5.8.0

2 release files

5.7.0

2 release files

5.6.0

2 release files

5.5.1

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.1

2 release files

5.1.1

2 release files

5.0.8

2 release files

5.0.7

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

4.42.0

2 release files

3.19.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page