stadt-land-energie-projekt / sl-app

The (django) webapp for the scenario-explorer of the "Stadt-Land-Energie" project.
https://stadt-land-energie.apps.rl-institut.de/
Other
1 stars 1 forks source link

Stadt-Land-Energie Webapp

The (django) webapp for the scenario-explorer of the "Stadt-Land-Energie" project.

Built with Cookiecutter Django Black code style

License: GPLv3

Settings

Moved to settings.

Basic Commands

Setting Up Your Users

For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.

Celery

This app comes with Celery.

To run a celery worker:

cd slapp
celery -A config.celery_app worker -l info

Please note: For Celery's import magic to work, it is important where the celery commands are run. If you are in the same folder with manage.py, you should be right.

To run periodic tasks, you'll need to start the celery beat scheduler service. You can start it as a standalone process:

cd slapp
celery -A config.celery_app beat

or you can embed the beat service inside a worker with the -B option (not recommended for production use):

cd slapp
celery -A config.celery_app worker -B -l info

Sentry

Sentry is an error logging aggregator service. You can sign up for a free account at https://sentry.io/signup/?code=cookiecutter or download and host it yourself. The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application.

You must set the DSN url in production.

Load data into application

First you have to set up all tables in the database by runnning:

python manage.py migrate

Afterwards you have to load in data. To simplify data commands a Makefile has been added, which can be used by command make. You can load all data by running (or you can run them one-by-one):

make load_regions load_data

And you can empty all data by running:

make empty_data empty_regions

Deployment

This application is ready to be deployed via Caprover. Make sure to define the following Environmental Variables:

REDIS_URL= DATABASE_URL=postgis:// DJANGO_DEBUG=False DJANGO_SETTINGS_MODULE=config.settings.production DJANGO_SECRET_KEY= DJANGO_ADMIN_URL= DJANGO_ALLOWED_HOSTS= DJANGO_ACCOUNT_ALLOW_REGISTRATION=True SENTRY_DSN= POSTGRES_HOST= POSTGRES_PORT= POSTGRES_DB= POSTGRES_USER= POSTGRES_PASSWORD= STARTUP_COMMAND=/start CELERY_BROKER_URL=redis:// MAP_ENGINE_TILING_SERVICE_TOKEN= MAP_ENGINE_TILING_SERVICE_STYLE_ID= MAP_ENGINE_USE_DISTILLED_MVTS=

To upload new data, its is probably the easiest to make them work locally, create a backup and use that backup on the target postgres/gis:

Docker

See detailed cookiecutter-django Docker documentation.