Commit a1d41575 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

More development guide

parent 8266217c
......@@ -5,7 +5,7 @@
* Install python3 and virtualenv
* Create a virtualenv and install the requirements
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
......@@ -14,7 +14,7 @@ pip install -r requirements.txt
* Create a database (with sqlite, postgres, …)
* Create a config file
......@@ -25,17 +25,49 @@ cp
* Fill your database
./ db upgrade
## Running the program
Run (in two terminals, one for the server and one for celery):
source venv/bin/activate
./ runserver
source venv/bin/activate
The website will run on `localhost:5000`.
## Data model
The data model is defined in `models/`.
Each type should inherit from `DatabaseModel` and have a method `get_parent()`, which is responsible for the right management and some magic.
## Server endpoints
The actual websites are defined in ``. They begin with the decorator `@app.route((route)` and return a string, usually through `render_template(template, **parameters)`.
There can be more decorators inbetween `app.route` and the function.
A simple website might look like this:
def documentation():
todostates = list(TodoState)
name_to_state = TodoState.get_name_to_state()
return render_template("documentation.html", todostates=todostates, name_to_state=name_to_state)
### Decorators
* `app.route(route)`: Defines for which URLs this function will be called.
- The route may contain variables: `"/type/edit/<int:protocoltype:id>"`. These will be passed to the function.
- Additionally, allowed HTTP methods may be defined: `@app.route("/type/new", methods=["GET", "POST"])`. The default is `GET`, but endpoints for forms require `POST` as well.
* `login_required`: Anonymous users will be redirected to the login page.
* `group_required(group)`: Users without this group will see an error message.
* `db_lookup(DataModel)`: Looks up an element of this type. The route needs to have an argument "{model_name}_id".
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment