================================
AURA Steering: Program Scheduler
================================

Installation
------------

If you have a working Docker environment, do::

    $ docker build -t pv_container .
    $ docker run -p 8000:8000 -d pv_container:latest

and log into it at http://127.0.0.1:8000/admin/ with username "admin" and password "admin". Full setup without Docker is done as described below.

To get setup you must have the following installed:

* PostgresSQL or MySQL client development libraries
* JPEG library development files
* Python 3 including development files

In Debian or Ubuntu (or derivatives) you should be able to achieve this with this command:

* Using PostgreSQL::

    $ sudo apt-get install postgresql postgresql-contrib libjpeg-dev python3 python3-dev

* Using MySQL::

    $ sudo apt-get install libmysqlclient-dev libjpeg-dev python3 python3-dev

Setting up the environment
--------------------------

Create a virtual environment where the dependencies will live::

    $ python3 -m venv python
    $ source python/bin/activate
    (python)$

Change into the base directory of this software and install the project dependencies::

    (python)$ pip install -r requirements.txt

Setting up the configuration
----------------------------

By default the project is set up to run on a SQLite database.

Create a file ``pv/local_settings.py`` and add at least the following line::

    SECRET_KEY = 'secret key'

(obviously replacing "secret key" with a key of your choice).

Setting up PostgreSQL
---------------------

We recommend using PostgreSQL in order to be able to use the collation utf8mb64_unicode_ci and thus being able to display all languages.

To use PostgreSQL, add the following to your ``local_settings.py`` (before migrating) and add your credentials::

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': '',
            'USER': '',
            'PASSWORD': '',
            'HOST': 'localhost',
            'PORT': '5432'
        }
    }

Setting up MySQL
----------------

**Note:** When adding your database, make sure you **don't** use the collation utf8mb4_unicode_ci or you will get a key length error during migration. (use e.g. utf8_general_ci instead).

To use MySQL, add the following to your ``local_settings.py`` (before migrating)::

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'OPTIONS': {
                'read_default_file': os.path.join(PROJECT_DIR, 'mysql.cnf'),
            },
        }
    }

Create a file ``pv/mysql.cnf`` and give your MySQL credentials::

    [client]
    database =
    host = localhost
    port = 3306
    user =
    password =
    default-character-set = utf8

Setting up the database
-----------------------

Then run::

    (python)$ python manage.py migrate
    (python)$ python manage.py loaddata program/fixtures/*.yaml

Adding an admin user
--------------------

In order to create an admin user (which you will need to login to the webinterface after the next step) run::

    (python)$ python manage.py createsuperuser

Running a web server
--------------------

In development you should run::

    (python)$ python manage.py runserver


After this you can open http://127.0.0.1:8000/admin in your browser and log in with username "admin" and password "admin".

Make sure to change your password by visiting http://127.0.0.1:8000/admin/auth/user/1/password/