Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DWPF-1481 Update readme #480

Merged
merged 11 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
DJANGO_SETTINGS_MODULE="config.settings.local"
SECRET_KEY="A_RANDOM_SECRET_KEY"
DJANGO_SETTINGS_MODULE=config.settings.local
SECRET_KEY=super-secret-key
ALLOWED_HOSTS="*"
DEBUG="True"
DEBUG=True
DISABLE_COLLECTSTATIC="0"

# Authbroker
AUTHBROKER_CLIENT_ID="get-from-vault"
AUTHBROKER_CLIENT_SECRET="get-from-vault"
AUTHBROKER_URL="get-from-vault"
AUTHBROKER_CLIENT_ID=copy-from-dev-environment
AUTHBROKER_CLIENT_SECRET=copy-from-dev-environment
AUTHBROKER_URL=copy-from-dev-environment

# ClamAV
CLAM_AV_DOMAIN=
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Run tests
run: make pytest

- name: Bring up chrome
run: docker compose up -d chrome

- name: Run BDD tests
run: make bdd

Expand Down
132 changes: 54 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,79 @@
# FFT
# FFT (Financial Forecast Tool)

## The Project
## Requirements

## Set up
- [docker](https://docs.docker.com/engine/install/)
- [poetry](https://python-poetry.org/docs/#installation)

A database called "fido" will be automatically created.
## Local setup

Run the following to perform initial migrations:
First you will need to make a copy of the `.env.example` file and rename it to `.env`.
This file contains most of the environment variables that the project needs to run.

```
make migrate
```

In order to add stub data for local development purposes run:

```
make create-stub-data
```bash
cp .env.example .env
```

You can add forecast data if you are developing forecast related functions:
Fill out the required variables in your `.env` file.

```
docker-compose run web python manage.py create_stub_forecast_data
```
> [!TIP]
> For the `AUTHBROKER_CLIENT_ID`, `AUTHBROKER_CLIENT_SECRET` and `AUTHBROKER_URL`
> variables, ask a member of the team to assist you in getting the values from the dev
> environment.

You can add Gift and Hospitality data if you are developing Gift and Hospitality related functions:
In a terminal run the `make setup` command from the project’s root directory.

```
make gift-hospitality-table
```bash
make setup
alsyx marked this conversation as resolved.
Show resolved Hide resolved
```

Now access any page within the site and log in with your single sign on credentials.
> [!NOTE]
> This command will run the initial migrations, create stub data and test users.
> A database named "fido" will be automatically created.

You now need to elevate your user permissions in order to access the admin tool. You can do this by running:
Open a second terminal and run the following to set up the frontend.

```
make elevate
```

### Compile the front end

```
```bash
# install the dependencies
npm install
make collectstatic
# start the dev server
npm run dev
```

### Environment variables
You should now be able to access the application at http://localhost:8000/.

You need to populate the .env file in the project root folder with the following variables:
If you want full admin access, you can elevate your by running:

- AUTHBROKER_CLIENT_ID
- AUTHBROKER_CLIENT_SECRET
```bash
make elevate
```

These can be provided by a member of the team.
> [!TIP]
> Don't forget to refresh the page.

### Integration between Django and React
## Local Development

The process described in this post was followed:
https://www.techiediaries.com/django-react-rest/
If you can connect to the dev environment but still have issues such as; `403 - Forbidden Error` on your local, there are few steps you can follow to resolve this:

To enable the forecast edit interface:
- Using dev tools on your browser, go to Application tab and clear data for Local Storage, Session Storage and Cookies.

```
npm start
```
- If the problem persists you may need to temporarily pause your VPN while you work on FFT on your local.

### Running docker-compose run with port access
## Running docker-compose run with port access

```
docker-compose run --service-ports
```

### Important notes on design
## Important notes on design

We use Django Guardian for model instance level permissions https://github.com/django-guardian/django-guardian

Django Guardian **should not be used directly**. There is a set of wrapper functions in _forecast.permission_shortcuts_

These add an additional permission check for the user being able to view forecasts at all.

### Creating data/non-auto migrations
## Creating data/non-auto migrations

When adding data or non-auto generated migrations, please use the convention:

Expand All @@ -93,45 +87,27 @@ for example:
0004_data_20200501_1345
```

### Running manage.py on an app droplet

```
/home/vcap/deps/1/bin/python3.6 ~/app/manage.py
```

### Running BDD tests
## Running the BDD tests

## Run BDD front end from host machine
Run the chrome container:

```bash
docker compose up -d chrome
```
npm run bdd
``

## SSH into web container
Build the frontend assets:

```
docker-compose exec web bash
```bash
npm run bdd
```

## Run BDD tests
Run the tests:

```bash
make bdd
```
python manage.py behave --settings=config.settings.bdd
```

### Notes

In order to get the node docker container working, this guide was followed: https://jdlm.info/articles/2019/09/06/lessons-building-node-app-docker.html

### Product URLs

#### Dev URL

https://fft.trade.dev.uktrade.digital/core/

#### Production URL

https://fft.trade.gov.uk/core/
## Notes

### Managing user permissions

Expand All @@ -144,20 +120,20 @@ https://fft.trade.gov.uk/core/

The names of the management commands denote their function.

### Permissions within the system
## Permissions within the system

#### Any logged in SSO user
### Any logged in SSO user

- Access Chart of Account Gifts and Hospitality Register

#### Specific permissions
### Specific permissions

- Upload budget and Oracle actuals file
- Download Oscar report file
- View forecast (permission to view all forecast data)
- Edit 1 - n cost centres (specific user can edit cost centre data)

#### Migrating to new user model (to be removed once complete)
### Migrating to new user model (to be removed once complete)

- Take the system off line
- Add username field to HistoricalUser table (max length 150, allow null)
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ services:
- "6379:6379"

chrome:
image: seleniarm/standalone-chromium:latest
image: selenium/standalone-chrome:latest
shm_size: 2gb
depends_on:
- web
ports:
- "4444:4444"
profiles:
- selenium