devfund-website/README.md
Anna Sirota b6c4ee7ff1 Replace poetry with requirements{,_dev,_prod}.txt
Accidental backward-incompatible changes appear regularly in poetry,
which leads to a regular chore of fixing this part of tooling,
or having to stay on the old version of it for a very long time,
which is bound to break.
2024-07-01 17:11:03 +02:00

124 lines
3.8 KiB
Markdown

# Blender Development Fund
## Requirements
* Python 3.10
* [virtualenv](https://pypi.org/project/virtualenv/)
* [PostgreSQL](https://www.postgresql.org/download/)
Recommended for local development:
* [virtualenvwrapper](https://pypi.org/project/virtualenvwrapper/)
`virtualenvwrapper` adds commands for naming, creating, listing, activating and deactivating
Python `virtualenv`s, which makes it much easier to work on various Python projects.
If you prefer not to use it, any other way of creating a `virtualenv`
or [venv](https://docs.python.org/3.10/library/venv.html) will do.
## Setting up
Make a copy of example settings first:
cp blender_fund/settings.example.py blender_fund/settings.py
Initialise the submodule included into this repo:
git submodule update --init
To create a new Blender Development Fund database, run this as the PostgreSQL root user:
CREATE USER blender_fund CREATEDB PASSWORD 'blender_fund';
CREATE DATABASE blender_fund OWNER blender_fund;
CREATE SCHEMA blender_fund;
GRANT ALL ON schema blender_fund TO blender_fund;
and change `blender_fund` to a random password that you also store in the `settings.py` file.
Alternatively, change the password using:
ALTER ROLE blender_fund WITH PASSWORD 'new_password';
In case of production, omit `CREATEDB` and make sure that both `postgres` and `blender_fund` users have secure hard to guess passwords set.
While inside project's directory, run the following to install project dependencies.
Note that path to `python3.10` binary might differ in your OS,
adjust the `mkvirtualenv` command accordingly:
```
mkvirtualenv fund -a `pwd` -p /usr/bin/python3.10
pip install -r requirements_dev.txt
./manage.py migrate
./manage.py loaddata systemuser devfund default_site
./manage.py collectmedia --noinput
./manage.py runserver 8010
./manage.py createsuperuser
```
The last command creates an admin account that can be used to log in at http://fund.local:8010/admin/.
### Working with `virtualenvwrapper`
In addition to `mkvirtualenv` mentioned above, the following commands are useful:
* use `workon fund` to go to Fund's project directory and activate its `virtualenv`;
* use `deactivate` to "exit" it;
* use `lsvirtualenv` to list existing `virtualenv`s;
* use `rmvirtualenv fund` to delete Fund's `virtualenv`.
## CMS
We use [Wagtail](https://wagtail.io/) as CMS for providing access to dynamic content of the website,
such as page titles, calls to action, or entire pages. The CMS is accessible at the `/cms` endpoint.
Note: we are currently using a development version of Wagtail, therefore we need to build the
static assets for the package ourselves. Check the warning in the startup log for more info on
how to do it.
## Stripe integration
TODO improve this section.
Follow the official guide for setting up Stripe CLI: https://stripe.com/docs/development/quickstart
### Webhook testing
Run a local listener that will make webhook requests to your development server:
```
stripe listen --forward-to fund.local:8010/webhooks/stripe/
```
Run background tasks that are created by the webhook code:
```
./manage.py process_tasks
```
## Documentation
```
cd docs
mkdocs serve -a localhost:8080
```
## Testing
Run `./manage.py test --parallel` to run all project's tests.
Use the `--reuse-db` option to speed up subsequent test runs.
However, this skips the database migrations; add `--create-db` on the CLI to
recreate the test database and run all the migrations when necessary.
## GeoIP
The GeoIP database was downloaded from
[GeoLite2-Country](http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz)
## Deployment
* Merge the required commits from `master` into `production` branch
* Run unittests
* Push `production` to origin
* Run `cd playbooks; ./ansible.sh -i environment/production deploy.yaml`