Git Product home page Git Product logo

do-prace-na-kole's Introduction

Do Prace na Kole (Ride to work by Bike) competion django app

The DPNK django application was developed to power the Do Práce na Kole bike to work competition run by the non-profit Auto*mat organization in the Czech Republic. With some work, you can modify it to run your own bike to work competition in your home country.

This readme file is intended to document how to develop and deploy the code.

Do práce na kole is designed to use Python 3.4+ and Django 2.1

Dependencies

  • Docker Engine
  • Docker Compose

Check docker documentation for installation instructions

Setting up the dev env

Click thumbnail for video instructions.

Alt text for your video

Check out and setup repo

$ git clone https://github.com/auto-mat/do-prace-na-kole.git
$ cd do-prace-na-kole

Create a docker.env file

$ cp docker.env.sample docker.env
$ $EDITOR docker.env

Building the docker images

$ make docker-compose

Setting up the database

In a separate terminal window:

$ ./develop.sh
$ ./setup.sh

Launching the development webserver

$ ./develop.sh
$ python3 manage.py runserver 0.0.0.0:8000

Clone and launch the front end server according to its own docs: https://github.com/auto-mat/do-prace-na-kole-frontend

Running tests

Running tests can be done with the command

pytest apps

In order to get a fast test loop, start out by running pytest apps then edit your local version of the django migrate command (found in ./pyenv/.cache/pypoetry/virtualenvs/do-prace-na-kole-bQ0wwWJR-py3.9/lib/python3.9/site-packages/django/core/management/commands/migrate.py) so that the handle method starts with return.

Finally run

./single-pytest.sh apps/dpnk/test/pytest/test_py_results.py

Replacing test_py_results.py with the specific test file you want to run.

Open the web app

Go to http://test.lvh.me:8021/.

Backing up your local development database

Once you have your test environment working, it's a good idea to back up your database.

First stop docker compose

$ docker-compose down

Then copy db folder

$ cp -r ./db ./db-bk

Deployment

Every time you push changes to github, new builds will be built. In this case, a build is a docker image.

In order to deploy to production you should first deploy to test, then, after testing a bit, look at the build number on test. Deployment is done by updating build numbers in the kubernetes config. The build number can be found at the bottom of the menu. It is in a format like 2021.1212 . 2021.24 which stands for <backend-build-number> . <frontend-build-number>.

Deploying the frontend is similar. There is a script.

./scripts/deploy_frontend --help

Which helps you deploy frontend builds. This script is self documenting. To see it's documentation simply run the script with the --help flag.

Connecting to test and production servers (bash and python shell)

Use kubectl.

$ kubectl get pods | grep dpnk

Get a bash shell with

$ kubectl exec -it <pod-id> -- bash

Once you connect you can get a python shell with

# poetry shell
# python3 manage.py shell_plus

do-prace-na-kole's People

Contributors

daaniam avatar dependabot[bot] avatar nutrie23 avatar pavelfilippi avatar petrdlouhy avatar rebierko avatar timthelion avatar tmszi avatar twentyfortysix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

do-prace-na-kole's Issues

Nefunguje chaining ve změně týmů

Chaining při změně týmu (/tym/) nefunguje. Příčinou je verze django-smart-selects - v requirements.freeze je 1.5.4 se kterou je problém, s verzí 1.5.3 mi to funguje.

Ideální by bylo udělat úpravy v kódu, aby to fungovalo i s nejnověší verzí.

celery beat error

dpnk-beat_1   | [2019-01-09 15:32:09,663: CRITICAL/MainProcess] beat raised exce
ption <class 'ValueError'>: ValueError('astimezone() cannot be applied to a naiv
e datetime',)
dpnk-beat_1   | Traceback (most recent call last):
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/celery/apps/beat.
py", line 109, in start_scheduler
dpnk-beat_1   |     service.start()
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/celery/beat.py", 
line 588, in start
dpnk-beat_1   |     interval = self.scheduler.tick()
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/celery/beat.py", 
line 293, in tick
dpnk-beat_1   |     self.populate_heap()
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/celery/beat.py", 
line 267, in populate_heap
dpnk-beat_1   |     is_due, next_call_delay = entry.is_due()
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/django_celery_beat/schedulers.py", line 129, in is_due
dpnk-beat_1   |     return self.schedule.is_due(self.last_run_at)
dpnk-beat_1   |   File "/usr/local/lib/python3.5/site-packages/django_celery_beat/tzcrontab.py", line 46, in is_due
dpnk-beat_1   |     last_run_at = last_run_at.astimezone(self.tz)
dpnk-beat_1   | ValueError: astimezone() cannot be applied to a naive datetime

Update Djanga na verzi 2.1

Bude potřeba udělat před březnem, ale je výhodnější s tím počkat, protože se zvýší podpora v externích aplikacích.

Automatizovat generování PDF dávek a nahrávání do systému GLS

Spouštět skripty generující PDF se štítky pro GLS na serveru v rámci celery.

Bylo by dobré napřed vyřešit #14, protože na tom zjistíme, co to obnáší.

Také je potřeba si dát pozor, abychom velikostí generovaného souboru neshodili instanci AWS, nebo abychom zbytečně nezvýšili velikost Docker souboru (a tím pádem nezvýšili dobu zřizování nové instance).

Zjednodušit administraci Uživatelského profilu

Odstranit checky, které mohou administrátora zarazit při ukládání změn:

  • Nastavit defaultní částku platby na 0
  • Kontrola odstranění týmu zaplacenému musí fungovat jen když se opravdu tým odstraňuje.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.