GithubHelp home page GithubHelp logo

notifications-template-preview's Introduction

notifications-template-preview

GOV.UK Notify template preview service. Generates PNG and PDF previews of letter templates created in the GOV.UK Notify admin app.

First-time setup

Since it's run in docker on PaaS, it's recommended that you use docker to run this locally.

  make prepare-docker-build-image

This will create the docker container and install the dependencies.

Tests

These can only be run when the app is not running due to port clashes

make test-with-docker

This script will run all the tests. py.test is used for testing.

Running tests will also apply syntax checking, using pycodestyle.

Running the application

make run-with-docker

Then visit your app at http://localhost:6013/. For authenticated endpoints, HTTP Token Authentication is used - by default, locally it's set to my-secret-key.

If you want to run this locally, follow these instructions:

hitting the application manually

curl \
  -X POST \
  -H "Authorization: Token my-secret-key" \
  -H "Content-type: application/json" \
  -d '{
    "template":{
      "subject": "foo",
      "content": "bar"
    },
    "values": null,
    "letter_contact_block": "baz",
    "dvla_org_id": "001"
  }'
  http://localhost:6013/preview.pdf

Deploying

You shouldn’t need to deploy this manually because there’s a pipeline setup in Jenkins. If you do want to deploy it manually, you'll need the notify-credentials repo set up locally.

make (sandbox|preview|staging|production) upload-to-dockerhub
make (sandbox|preview|staging|production) cf-deploy

Running locally

During development it may be preferable to run locally.

If you haven't installed the app yet follow these steps -

# binary dependencies
brew install imagemagick@6 ghostscript cairo pango
brew link --force imagemagick@6

mkvirtualenv -p /usr/local/bin/python3 notifications-template-preview
pip install -r requirements.txt

# create a version file
make _generate-version-file

You will also need to set VCAP_SERVICES (extracted from Makefile) -

export VCAP_SERVICES='{"user-provided":[{"credentials":{"api_host": "some_domain","api_key":"my-secret-key"},"label":"user-provided","name":"notify-template-preview","syslog_drain_url":"","tags":[],"volume_mounts":[]}]}'

Then call the run app script -

./scripts/run_app.sh 6013

Thereafter activate the virtualenv prior to executing the run app script above -

workon notifications-template-preview

notifications-template-preview's People

Contributors

quis avatar leohemsted avatar sakisv avatar pyup-bot avatar venusbb avatar kentsanggds avatar imdadahad avatar

Stargazers

Keyth M Citizen  avatar

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.