Skip to content

Commit e184be5

Browse files
authored
Better fixtures for local development & Review Apps (#134)
* [docs] Update contributing guide for installing pip packages & i18n * Install factory_boy * Add UserFactory and ProjectFactory * Install django-extensions, IPython * Add factories * Continue adding factories * Add fuzziness to results * Add more pages and environments to fixtures * Fix RuntimeWarning due to timezones Warning fixed: DateTimeField Audit.created_at received a naive datetime (2020-03-19 17:47:08.432696) while time zone support is active. * Use new fixtures in docs & review apps * Add doc section to reset DB data
1 parent c8d8a9d commit e184be5

File tree

9 files changed

+461
-54
lines changed

9 files changed

+461
-54
lines changed

CONTRIBUTING.md

+46-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ To edit a piece of documentation, you can click on the “Edit this page” link
1616

1717
![Edit this doc button](/docs/static/img/edit-docs.png)
1818

19+
## Internationalization
20+
21+
Falco uses [`react-intl`](https://github.com/formatjs/react-intl) under the hood to manage internationalization. It detects the language of the user’s browser and serves that locale if available, otherwise defaults to English.
22+
If you spot a mistake in one of the translations available, or would like to translate Falco to your language, please edit (or create) the appropriate JSON file in `frontend/translations` and submit a pull request.
23+
1924
## Local development on Falco
2025

2126
This section will guide you through installing Falco on your development machine, so that you can work on your feature or bug fix locally before submitting a PR.
@@ -68,4 +73,44 @@ The project should now be running at [localhost:3000](http://localhost:3000). Yo
6873
To access both these interfaces, you can login using the following credentials:
6974

7075
- username: `admin`
71-
- password: `admin`
76+
- password: `admin`
77+
78+
### To reset the database to its original state (with fixtures)
79+
80+
- Ensure that nothing is connected to your database (Django shell, Postgres GUI…)
81+
- Run `docker-compose exec backend ./manage.py reset_db`
82+
- Run `make fixtures/load`
83+
84+
### Add a new pip package to Falco’s backend
85+
86+
To add a Django package in Falco’s backend:
87+
88+
- Start the backend:
89+
90+
```sh
91+
make backend/start
92+
```
93+
94+
- Once the backend is up and running, install your package inside the docker container (this may take a few minutes):
95+
96+
```sh
97+
docker exec -it falco_backend_1 pipenv install <package_name>==<package_version>
98+
```
99+
100+
_This will install your package, then update Pipfile and Pipfile.lock files accordingly._
101+
102+
- Once package is installed, stop backend using `Ctrl + C`
103+
104+
- To make your package installation persistent, you have to rebuild all Django containers (this may also take a few minutes):
105+
106+
```sh
107+
docker-compose build --no-cache backend
108+
109+
docker-compose build --no-cache celery
110+
```
111+
112+
- Relaunch backend and ensure you have no error:
113+
```sh
114+
make backend/start
115+
```
116+
- Enjoy! 🎉

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ db/connect:
2222
docker exec -it falco_db_1 psql -Upostgres postgres
2323

2424
fixtures/load:
25-
docker-compose exec backend ./manage.py loaddata fixtures/fixtures.json
25+
docker-compose exec backend ./manage.py load_fixtures
2626

2727
frontend/install: frontend/.env
2828
yarn --cwd frontend install

backend/Pipfile

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ django-fernet-fields = "==0.6"
2020
whitenoise = "==5.0.1"
2121
django-heroku = "==0.3.1"
2222
drf-yasg = "==1.17.0"
23+
factory-boy = "==2.12.0"
24+
django-extensions = "==2.2.8"
25+
ipython = "==7.9.0"
2326

2427
[dev-packages]
2528
"flake8" = "==3.7.7"

0 commit comments

Comments
 (0)