waschag-tvk / pywaschedv

MIT License
1 stars 0 forks source link

pywaschedv

Install Instructions

In all the methods below, you first please clone this repository, and navigate to top level project folder.

Quickest way

Using pipenv, you just need to run pipenv install. Run Django by pipenv run python manage.py <options see under "Usage"> or you can enter a shell by pipenv shell and you don’t need to prefix pipenv run.

Traditional way

If you have a very old distribution

If you have something like Debian Wheezy, installing either virtualenv or python>=3.5 is not that easy, you can use conda.

Alternative way on a very old Debian distribution (deprecated)

This method works, but is rather hacky and not recommended.

Additional setup to be done before use

The repository does not contain all migration files. Therefore before first use of your instance, run

python manage.py makemigrations
python manage.py migrate

Further, quick setup of a waschuser for god and three machines as required at TvK you can navigate to http://localhost:$DJANGO_PORT/wasch/setup/. You need to login as superuser (change password for WaschRoss in GodOnlyBackend as required). As GodOnlyBackend depends on crypt, it only works in a POSIX environment. You can alternatively create a different superuser using manage.py. This method has not been rigorously tested yet though.

All created machines are initially disabled. Enable them as appropriate using the Django admin.

Usage

Like any django project you can start it with

 python manage.py runserver $SOME_PORT

PyCharm

I'd also highly recommend using PyCharm, best way to set up (imho ;)) is as follows:

enteapi

For development of a remote desktop application for the activation of appointments, pywaschedv provides the enteapi RESTful API based on the Django REST framework.

Usage:

import requests
# get available appointments
appointments = requests.get('http://localhost/enteapi/v1/appointment/').json()
# authenticate
token = requests.post(
    'http://localhost/enteapi/token-auth/',
    json={"username": "Me", "password": "secret123"},
    ).json()['token']
pk = appointments[0]['pk']
# activate the first available appointment
requests.post(
    'http://localhost/enteapi/v1/appointment/{:d}/activate/'.format(pk),
    json={"enteId": 1},
    headers={'Authorization': 'JWT ' + token})
# bonus: see the latest actual users for each machine
requests.get(
    'http://localhost/enteapi/v1/appointment/last_used_for_each_machine/')