Skip to content

konradko/directory-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

directory-api

code-climate-image circle-ci-image codecov-image gitflow-image calver-image

Export Directory API service


Development

Installing

$ git clone https://github.com/uktrade/directory-api
$ cd directory-api
$ virtualenv .venv -p python3.6
$ source .venv/bin/activate
$ pip install -r requirements_test.txt

Requirements

Python 3.6 Postgres 9.5 Redis

Configuration

Secrets such as API keys and environment specific configurations are placed in conf/.env - a file that is not added to version control. You will need to create that file locally in order for the project to run.

Running the webserver

$ source .venv/bin/activate
$ make debug_webserver

Running the tests

$ make debug_test

Development data

For development efficiency a dummy company can be loaded into the database from fixtures/development.json. To do this run:

$ make loaddata

To update fixtures/development.json with the current contents of the database run:

$ make dumpdata

Then check the contents of fixtures/development.json.

Celery

Celery beat

Run debug celery beat scheduler Requires Redis (e.g. Install and config Redis on Mac OS X via Homebrew for the Mac)

$ make debug_celery_beat_scheduler

Celery worker

Some tasks as executed asynchronously such as sending confirmation emails:

$ make debug_celery_worker

SSO

To make sso work locally add the following to your machine's /etc/hosts:

IP Adress URL
127.0.0.1 buyer.trade.great
127.0.0.1 supplier.trade.great
127.0.0.1 sso.trade.great
127.0.0.1 api.trade.great
127.0.0.1 profile.trade.great
127.0.0.1 exred.trade.great

Then log into directory-sso via sso.trade.great:8004

Note in production, the directory-sso session cookie is shared with all subdomains that are on the same parent domain as directory-sso. However in development we cannot share cookies between subdomains using localhost - that would be like trying to set a cookie for .com, which is not supported by any RFC.

Therefore to make cookie sharing work in development we need the apps to be running on subdomains. Some stipulations:

  • directory-ui-supplier and directory-sso must both be running on sibling subdomains (with same parent domain)
  • directory-sso must be told to target cookies at the parent domain.

Manage commands

Create registered company in your local environment:

cmd="create_registered_company ch_id_max_8chrs" make debug_manage

Linux setup

Linux (Fedora 27) instructions are available here

Helpful links

Related projects:

https://github.com/uktrade?q=directory https://github.com/uktrade?q=great

About

Directory of Exporters API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 94.1%
  • HTML 5.1%
  • Makefile 0.8%