diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0383f52..aac8a4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: services: postgres: - image: postgis/postgis + image: postgis/postgis:15-3.4 env: POSTGRES_USER: osmcal POSTGRES_PASSWORD: postgres diff --git a/README.md b/README.md index 135e40e..f63bdb8 100644 --- a/README.md +++ b/README.md @@ -13,62 +13,22 @@ Please look at [OpenStreetMap Calendar Documentation](https://osmcal.org/documen ## Developer Documentation -This is a Django application, it uses [poetry](https://python-poetry.org) for managing dependencies. Please look at their documentation for installation instructions. +The repo contains a [dev container](https://containers.dev) configuration, so you can develop without having to install all the dependencies on your machine manually. VS Code and PyCharm/IntelliJ have integrated support and you can even use Github Codespaces. -We support Python ≥ 3.8 and PostgreSQL ≥ 10. +Alternatively you can install like any other Python/Django project. We're using [poetry](https://python-poetry.org) for managing dependencies. Please look at their documentation for installation instructions. -### Database - -You need a running PostgreSQL database. There are two options: Running it locally or using Docker. - -#### A) Local Installation -Create a PostgreSQL user called `osmcal` and a database `osmcal` with the owner set to `osmcal`. E.g. -``` -CREATE ROLE osmcal WITH LOGIN ENCRYPTED PASSWORD 'postgres'; -CREATE DATABASE osmcal OWNER osmcal; -CREATE EXTENSION postgis; -``` - -Make sure you have following line in your [pg_hba.conf](https://www.postgresql.org/docs/12/auth-pg-hba-conf.html), so osmcal need a password to log in: -``` -local all all trust -``` -Alternatively, you can set your DB password using the `POSTGRES_PASSWORD` environment variable, c.f. the following section on Docker. - - -#### B) Docker - -``` -docker run -e POSTGRES_DB='osmcal' -e POSTGRES_USER='osmcal' -e POSTGRES_PASSWORD='postgres' --name osmcaldb postgis/postgis -``` - -*Note:* You can use `docker start osmcaldb` and `docker stop osmcaldb` after first run of the command above. - -When using database in docker with the command above, the database host is: - -``` -export OSMCAL_PG_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' osmcaldb) -``` - -and database password is: - -``` -export OSMCAL_PG_PASSWORD='postgres' -``` +We support Python ≥ 3.11 and PostgreSQL ≥ 15. (Older versions might work, but no guarantees). -### Virtual Environment +### Database -Use *poetry* to create a virtual environment. Then, install the dependencies: +You need a running PostgreSQL database with PostGIS installed. If you're using the dev container, the DB is automatically started and set up. -``` -cd openstreetmap-calendar -poetry install -``` +If you set this up manually, make sure you have an empty DB before starting. By default we're using ### Running Tests ``` -poetry run ./manage.py test +make test ``` ### Developer Server @@ -78,38 +38,21 @@ In order to facilitate testing, you can use a fake login locally without having To prepare for application launch run the database migrations: ``` -poetry run ./manage.py migrate +make migrate ``` and then the local server: ``` -poetry run ./manage.py runserver +make devserver ``` If you need test data, you can load some using: ``` -poetry run ./manage.py loaddata osmcal/fixtures/demo.yaml +make fixtures ``` ## API Documentation The API is described using OpenAPI 3, the schema is located in `/api/schema/`. The currently live version is [visible here](https://osmcal.org/static/api.html). - -## OAuth Setup - -If want to test the OAuth flow, you need to create an OAuth app first: - -1. Go to osm.org -> My Settings -> oauth settings -> bottom of the page (My Client Applications) -> Register your application. -2. Fill `Name` and `Main Application URL`. No restrictions here. -3. You *must* fill `Callback URL` with `http://localhost:8000/oauth/callback`. -4. Mark `read their user preferences.` -5. Click `Register`. - -When the application is registered on osm.org, set the respective environment variables used for oauth and copy *Consumer Key* and *Consumer Secret*: - -``` -export OSMCAL_OSM_KEY='...' -export OSMCAL_OSM_SECRET='...' -```