Giter Club home page Giter Club logo

ministryofjustice.vis's Introduction

Victims' Information Service

Dependencies

Installation

The project can also be run with Docker for local development - see Docker Installation

Clone the repository:

git clone [email protected]:ministryofjustice/vis.git

Next, create the environment and start it up:

cd vis
virtualenv env --prompt=\(vis\)

source env/bin/activate

Update pip to the latest version:

pip install -U pip

If you want to install GDAL run:

brew install gdal

However, it might take a long time to install and it's optional.

In case you want to skip that, just open requirements/dev.txt and comment out GDAL==1.11.2

Install python dependencies:

pip install -r requirements/dev.txt

Create the database inside postgres. Type psql to enter postgres, then enter:

CREATE DATABASE vis WITH ENCODING 'UTF-8';
\c vis
createuser postgres

Sync and migrate the database:

./manage.py migrate

Create superuser

./manage.py createsuperuser --username=admin

Load test fixtures

./manage.py loaddata glossary helplines police test_pages vis/fixtures/test_users.json

Fix PCC Page Permissions such that each PPC Page is owned by the corresponding user:

./manage.py fixpccpermissions

Install frontend packages:

npm install

Compile assets:

npm run build:dev  # gulp build:prod in production

In the main tab, start the runserver:

./manage.py runserver 8000

Frontend Development

Frontend assets are located in the vis/assets-src/ folder and are compiled using gulp.

Gulp tasks are split into individual task files in tasks/.

To watch assets and rebuild them after every change use this command:

npm run watch

It will automatically run gulp build:dev and then create a browsersync server which will run at http://localhost:3000. By default it will proxy the django app from http://localhost:8000. To change the port add a port argument to the watch command, eg:

gulp watch --port=8001

Police area maps

The maps used on the police pages are generated using Mapbox. The images are currently kept in vis/assets-src/images/pcc-maps/.

Generate maps

Make sure you have GDAL installed (if brew: brew install gdal).

Download the latest police area KML data from the police data downloads site.

Run the following command, replacing the items in brackets:

./manage.py generate_pcc_maps <mapbox_api_key> <mapbox_map_id> <png_width> <png_height> <kml_input_directory> <png_output_directory> --stroke-width=1.5 --stroke-color="#0E1010" --fill-color="#BCDBDC"

Url2png

The code uses url2png to take screenshots of pages.PCCPage.service_website_urls.

Check settings.base.py for settings.

Scheduling commands

There are two jobs that should/could be run in production.

  1. ./manage.py publish_scheduled_pages (every 10 mins). It uppdates the db when a page is published/unpublished

  2. ./manage.py generatestatic which is optional. It downloads the whole website, zips it and sends it to the email addresses specified in the env variable EXPORT_RECIPIENTS.

Zendesk

Zendesk integration for content feedback is supported.

Check settings.base.py for settings.

Docker Installation

Install

Setup

Create boot2docker VM:

$ boot2docker init

Start VM:

$ boot2docker start

Set up environment variables:

$ $(boot2docker shellinit)

Build the Docker images with Fig:

$ fig build

If you get the error:

SSL error: hostname '192.168.59.103' doesn't match 'boot2docker'

Then add 192.168.59.103 boot2docker to /etc/hosts and run export DOCKER_HOST=tcp://boot2docker:2376 (and add it to your .bashrc file).

Start

Django fixtures require setup on the first run only:

$ fig run django python manage.py loaddata vis/fixtures/test_users glossary helplines police test_pages vis/fixtures/test_users

Start it up:

$ fig up

The site should now be viewable in your browser at http://192.168.59.103:8000/ (or http://boot2docker:8000/ if you've added an /etc/hosts entry).

Deploy to Heroku

Just press the button: Deploy

ministryofjustice.vis's People

Contributors

ashb avatar bnewing avatar kerin avatar lgarvey avatar lukaszraczylo avatar marcofucci avatar maxawan avatar r4vi avatar richerry avatar ricicle avatar robyoung avatar teneightfive 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.