Django API server for the karrot frontend
Clone or download
tiltec Conflict resolution / issues (#616)
* sketch out cases implementation

* add basic functionality

* add tests etc

* implement ties

* restructure voting api

* some more testing

* rework voting API

* fix some tests

* add some more checks

* add basic websocket implementation

* add basic notifications

* add conversation message notification email support

* add todo

* add todo

* add two email templates

* add some stats

* hide sum score when voting is ongoing

* add more notifications

* don't send notifications to users who voted already

* fix stuff

* makemessages

* fix and refine emails

* handle case if affected user leaves group during case, rewrite is_decided into status

* add case type to stats

* change endpoint from /cases to /conflict-resolution

* add history entry on user removal

* apply some throttling

* clean up

* add case participant concept

prevents new editors from joining existing cases

* optimize group API

* require minimum amount of active editors to start conflict resolution

* reword

* rename case to groupcase to avoid name clash with Django's Case

* remove affected_user from options model

* rewrite conversation type from 'group case' to 'case'

* add custom push title for case messages

* fix user removal

* test user removal notification

* tame flake8

* fix some edge cases about cancelled cases

* update messages

* add template preview handlers, fix small template problems

* make case and conversations endpoint more efficient

* reword emails

* simplify voting API

* rename to issues

* fix up renaming

* add notifications towards affected user

* rename bits and bobs
Latest commit f2e068e Jan 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci merge base and dev dependency files Jan 4, 2019
.tx Follow Django standard for chinese language codes Oct 23, 2018
config Conflict resolution / issues (#616) Jan 21, 2019
foodsaving Conflict resolution / issues (#616) Jan 21, 2019
grafana snapshot grafana dashboards Dec 16, 2018
mjml Bump mjml from 4.3.0 to 4.3.1 in /mjml Jan 9, 2019
.coveragerc chore: rename yunity app to foodsaving Feb 14, 2017
.editorconfig Let the CI help us with updating locales (#580) Oct 4, 2018
.gitignore Add grafana dashboard snapshot (#575) Sep 1, 2018
.pyup.yml create pyup.io config file Jul 17, 2017
.style.yapf Use yapf for consistent formatting (#524) Jul 18, 2018
Dockerfile merge base and dev dependency files Jan 4, 2019
LICENSE Updating a few things in the repository. Mar 28, 2016
README.md Focus dev setup instructions (#520) Mar 4, 2018
SETUP.md Focus dev setup instructions (#520) Mar 4, 2018
babel.cfg Improve message extraction (#572) Aug 6, 2018
compile.py merge base and dev dependency files Jan 4, 2019
deploy.sh use deploy playbook again Mar 7, 2018
manage.py Use huey queue (#496) Feb 26, 2018
pytest.ini Use circleci 2 (#484) Feb 22, 2018
requirements.in downgrade to last compatible version of channels_redis Jan 21, 2019
requirements.txt downgrade to last compatible version of channels_redis Jan 21, 2019
setup.cfg ignore line break after binary operator Oct 28, 2018
sync.py merge base and dev dependency files Jan 4, 2019
yapf.py Improve yapf.py script Jul 19, 2018

README.md

karrot-backend

Django API server for the karrot frontend

Our issues are tracked in karrot-frontend. We plan to unite karrot-backend, karrot-frontend and related repos in near future.

CircleCI codecov

Developer setup

The recommended way to getting your developer environment setup is docker-compose - includes backend, frontend, mail catcher, postgres, redis, etc..

Head over to yunity/karrot-docker for further instructions.

If you can't or don't want to use docker-compose, look into SETUP.md for other ways.

Coding guidelines

We follow PEP8 with the same rules as the Django project. As always, the coding style may not apply at some parts. You can execute flake8 in the repository root to check your code.

Code will only be accepted into master if it passes the PEP8 test.

Using the API

A live instance of karrot is running at https://karrot.world/. See https://karrot.world/docs/ for API documentation. Most endpoints are only available to authenticated users. Be sure to create an account and log in to see all endpoints.

IDE

Most of karrot developers use PyCharm. We have some licenses available for the professional version. The free community edition also works well.

To get proper introspection and support from PyCharm, it's necessary to set up a virtualenv. Run this inside the backend directory:

virtualenv env
source ./env/bin/activate
pip install pip-tools
./sync.py

Django quick introduction

The manage.py application can be used to perform administrative tasks:

  • makemigrations: Create database migrations
  • migrate: Apply database migrations
  • shell_plus: (requires ipython) for playing in a django python environment
  • test: Run automated tests

You can launch them via docker-compose, for example:

docker-compose exec backend ./manage.py makemigrations
docker-compose exec backend ./manage.py migrate

If you spend too much time typing those long commands, consider creating your own bash aliases.

Parallel testing

Running the tests in parallel process can increase testing speed significantly. To execute the whole test suite on a CPU with 4 kernels, you may want to use:

docker-compose exec backend ./manage.py test --parallel 4

Email template viewer

When editing emails it's useful to be able to see how they will be rendered.

Assuming the server is running you can visit visit localhost:8000/_templates.

To compile the .mjml templates to .html.jinja2 files you can run:

cd mjml
yarn
./convert

If you want to watch for changes, and support hot reloading then run:

./convert --watch

(refresh your browser after starting the server as the websocket is not reconnecting)

Note: you should never edit .html.jinja2 files directly.

Enjoy! ... oh and be sure to visit https://mjml.io/documentation/#components to find some nice components to use.