In order to use the provided development environment install Docker Desktop for Mac or Windows. On Linux, make sure you have the latest version of Compose.
This project has a docker-compose.yml file, which will start the Django application on your local machine.
Clone the repository and start the development environment in the created directory:
docker compose up -d
(Should you recieve errors like docker/transport/unixconn.py
, try starting docker desktop first, then run the compose command.)
Now, the API is available at http://localhost:8000/api/.
curl http://localhost:8000/api/
# => {"users":"http://localhost:8000/api/users/"}
Access the console of the Docker container running the backend app:
docker compose exec app bash
python manage.py createsuperuser
TODO
Please use black as code formatter. https://black.readthedocs.io/en/stable/
We use # fmt: off
whenever we want to specify our own formatting style.
VSCode hints:
"python.formatting.provider": "black"
)root@123406906c90:/code# which python
Using the Docker extension
is recommended to develop in VSCode. It requires special ./.devcontainer
setting files hat a fellow developer can provide.
Configuration options are set through environment variables, all of which are listed in docker-compose.yml
.
/reports
: Radbügel Meldedialog/fixmyapp
: Xhain-Terrassen / Gastro app/permits
, https://api.fixmyberlin.de/admin/permits/ which are events that temporary take up parking space./fixmyapp
: Planungskarte, Happy-Bike-Index (HBI)/project
("Planungen") are part of the Planungskarte. The segments are created manually to reflect a "Planung"./question
(FAQ for the "Planungen panel")/section
, /sectiondetails
are what make up the HBI. The segments are extract from offical street data./sectionaccidents
/profile
are part of the HBI to create custom HBI versions; not used anymore.EVENT_RECIPIENT
(string): An email address to which email notifications for
accepted or rejected applications are sent be forwarded to the actual recipients.
EVENT_SIGNUPS_OPEN
(string): An iso 8601 formatted datetime which defines the
beginning of the event permit application signup timeframe.
If undefined, applications are always open. If the value can not be parsed, sign ups are always closed.
EVENT_SIGNUPS_CLOSE
(string): Equivalent for closing date and time.
/fixmyapp
: Spielstraßen / Playstreets appNote there is also spielstraßen.de which might be using the static geojson extract of this from github.com/FixMyBerlin/fixmy.spielstrassen
/fahrradparken
: radparken.info/survey
: Studie zur subjektiven Sicherheit im RadverkehrTODO
TODO
TODO
TODO
Get an overview of all commands available:
docker compose exec app bash
python manage.py
Run the test suite:
docker compose exec app bash
python manage.py test
Run the test suite with pdb for debugging
./manage.py test --pdb
Using debugpy:
You can enable interactive debugging through debugpy by setting the environment variable DEBUGPY=1
(e.g. through a .env
file).
Using pdb:
import pdb; pdb.set_trace()
– Break into the debugger from a running program.l
– List source code for the current file.a
– Print the argument list of the current function.p some_variable
– Evaluate the expression in the current context and print its value.Removes personal information from the database. By default it preserves data of staff.
python manage.py anonymizedata
Downloads content of S3 bucket to /tmp, filtered by path prefix. This command requires the environment variables AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
, AWS_S3_REGION_NAME
and AWS_STORAGE_BUCKET_NAME
to be set correctly.
python manage.py downloaddata Data/
Exports projects as GeoJSON intended for Mapbox.
python manage.py exportprojects > /tmp/projects.json
Exports sections as GeoJSON intended for Mapbox.
python manage.py exportsections > /tmp/sections.json
Similar to exportreports
, this command exports play street signups to a csv file.
python manage.py exportplaystreets spielstrassen.csv
This command exports GastroSignup entries, either in CSV or GeoJSON format. The GeoJSON format has an additional switch that allows exporting usage areas instead of the geolocation of the entry's shop.
The CSV format doesn't include usage areas and uploaded certificates.
The GeoJSON format doesn't include any personal information.
In order to export the requested usage areas in GeoJSON format into a file gastrosignup_area.geojson
:
python manage.py exportgastrosignups --format geojson --area gastrosignup_area.geojson
Bootstrap the database for HBI. Downloads and imports road and intersection data, section details and section accidents, also applying migrations.
python manage.py updatehbi
Imports sections from shape file. The file is usually downloaded from S3 with downloadfiles
.
python manage.py importsections /tmp/road_sections-v1.1.shp
python manage.py importsections /tmp/intersections-v1.1.shp
Imports section details including pictures and traffic information from CSV file. The file is usually downloaded from S3 with downloadfiles
.
python manage.py importsectiondetails /tmp/section_details-v1.1.csv
Import section accident data set, which references previously imported sections.
python manage.py importsectionaccidents /tmp/section_accidents-v1.1.csv
Updates project geometries from a shape file. The file is usually downloaded from S3 with downloadfiles
.
python manage.py updateprojectgeometries /tmp/projects.shp linestring
Uploads GeoJSON export of projects or sections (see exportprojects
and exportsetcions
) to Mapbox. This command requires the environment variables MAPBOX_UPLOAD_NAME_SECTIONS
, MAPBOX_UPLOAD_TILESET_SECTIONS
, MAPBOX_UPLOAD_NAME_PROJECTS
and MAPBOX_UPLOAD_TILESET_PROJECTS
to be set correctly.
python manage.py uploadtileset --dataset projects /tmp/projects.json
Export reports about bike stands in either CSV or GeoJSON format
python manage.py exportreports --format csv /tmp/reports.csv
Notes:
Import or update entries in the reports app from a CSV file.
The imported CSV file is required to have the columns;
reports.models.report
python manage.py importreports reports.csv
Batch send notifications, which are enqueued when a reports status is changed
python manage.py sendnotifications
This command requires the environment variables REPORTS_NOTIFICATION_CAMPAIGN
and REPORTS_NOTIFICATION_SENDER
to be set. You can send sample emails
containing all variations of the text templates using
python manage.py sendnotifications --send-samples your@email.org
Creates a backup using a given Heroku app, downloads it and uses it to overwrite the local database schema and contents. User data is anonymized in the process, except for staff users, who are preserved.
todo: Requires heroku tools? Only for heroku based installations.
./scripts/fetch_database.sh fixmyplatform