Skip to content
Snippets Groups Projects
readme.md 4.24 KiB
Newer Older
Jacek Lebioda's avatar
Jacek Lebioda committed
# SMart SCHeduling

[![coverage report](https://git-r3lab.uni.lu/NCER-PD/scheduling-system/badges/master/coverage.svg)](https://git-r3lab.uni.lu/NCER-PD/scheduling-system/commits/master)
Piotr Gawron's avatar
Piotr Gawron committed
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)

## Docker version
If you'd like to try out the application without preparing the environment, you can use Docker (you must have _Docker_ and _docker-compose_ installed):

```
# Navigate to the project's directory
docker-compose build && docker-compose up
# To add a new user, type in the new terminal:
docker-compose exec web sh
Piotr Gawron's avatar
Piotr Gawron committed
python manage.py superworker
Jacek Lebioda's avatar
Jacek Lebioda committed
## Required software (on ubuntu's OS family):
Piotr Gawron's avatar
Piotr Gawron committed
  - install required dependencies on ubuntu
```bash
sudo apt-get install python3, virtualenv, libcurl4-gnutls-dev, libpng-dev, libfreetype6-dev, libpq-dev, gcc, g++, python3-dev, libgnutls28-dev, libjpeg-dev, libfreetype6-dev, git
Valentin Groues's avatar
Valentin Groues committed
```
Piotr Gawron's avatar
Piotr Gawron committed
  - install nodejs
Valentin Groues's avatar
Valentin Groues committed
```
Piotr Gawron's avatar
Piotr Gawron committed
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install nodejs
Piotr Gawron's avatar
Piotr Gawron committed
## Developer project installation
  - clone smasch:
Piotr Gawron's avatar
Piotr Gawron committed
git clone ssh://git@git-r3lab-server.uni.lu:8022/NCER-PD/scheduling-system.git
Piotr Gawron's avatar
Piotr Gawron committed
  - setup virtualenv with clean python3 working environment and start using it. Important python3.6 or higher is required
Piotr Gawron's avatar
Piotr Gawron committed
cd scheduling-system
virtualenv env -p python3
. env/bin/activate
Piotr Gawron's avatar
Piotr Gawron committed
  - install smasch dependencies
Piotr Gawron's avatar
Piotr Gawron committed
pip install -r requirements.txt
pip install -r requirements-dev.txt
npm install
Piotr Gawron's avatar
Piotr Gawron committed
  - Create `local_settings.py` file in `smash/smash` directory by copying the template in `smash/smash/local_settings.template` and edit your local_setttings.py file to change your database connection data.
Piotr Gawron's avatar
Piotr Gawron committed
### Database configuration
There are two databases supported: `sqlite3` or `postgresql`. You can configure database connection in `smash/smash/local_settings.py`.
Piotr Gawron's avatar
Piotr Gawron committed
- sqlite3 database configuration looks like:
Piotr Gawron's avatar
Piotr Gawron committed
```python
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'db.sqlite3',
    }
Piotr Gawron's avatar
Piotr Gawron committed
- postgresql database configuration looks like:

```python3
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'smaschdb',
        'USER': 'smaschuser',
        'PASSWORD': 'smaschpassword',
        'HOST': 'localhost',
        'PORT': '',
        'TEST': {
            'NAME': 'dbtest',
        },
    }
Piotr Gawron's avatar
Piotr Gawron committed
```
Piotr Gawron's avatar
Piotr Gawron committed
After database connection is configured setup a database by applying migration scripts and create admin user
Piotr Gawron's avatar
Piotr Gawron committed
```bash
./manage.py migrate
./manage.py superworker -u admin -e test@test.lu -f John -l Doe
```
Piotr Gawron's avatar
Piotr Gawron committed
## Development    
Remember, that before working you have to activate _virtualenv_, by:
```
devel@host ~/home/smash/scheduling-system $ . env/bin/activate
```
Piotr Gawron's avatar
Piotr Gawron committed
In order to run development server, run:
```
devel@host ~/home/smash/scheduling-system/smash $ ./manage.py runserver
```
and go to `127.0.0.1:8000` in browser
Piotr Gawron's avatar
Piotr Gawron committed
### Mac Developers
Piotr Gawron's avatar
Piotr Gawron committed
In case of problems with the openssl version installed on the system:
Piotr Gawron's avatar
Piotr Gawron committed
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl --global-option=build_ext --global-option="-I/usr/local/Cellar/openssl/1.0.2k/include" --global-option="-L/usr/local/Cellar/openssl/1.0.2k/lib" --upgrade
pip install psycopg2 --global-option=build_ext --global-option="-I/usr/local/Cellar/openssl/1.0.2k/include" --global-option="-L/usr/local/Cellar/openssl/1.0.2k/lib" --upgrade
```
Piotr Gawron's avatar
Piotr Gawron committed

Piotr Gawron's avatar
Piotr Gawron committed
## Production deployment
Smasch can be deployed using debian package provided in lcsb repository:
```
echo "deb http://repo-r3lab.uni.lu/debian/ stable main" | tee /etc/apt/sources.list.d/repo-r3lab.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xcb185f4e31872412
apt-get update
apt-get install -y smasch
```
Piotr Gawron's avatar
Piotr Gawron committed

Piotr Gawron's avatar
Piotr Gawron committed
After smasch is installed you can start/stop it using systemd:
Piotr Gawron's avatar
Piotr Gawron committed
```
Piotr Gawron's avatar
Piotr Gawron committed
service smasch start
service smasch stop
Piotr Gawron's avatar
Piotr Gawron committed
```

Piotr Gawron's avatar
Piotr Gawron committed
Configuration of smasch (`local_settings.py`) is in `/etc/smasch/smasch.py`.

### Disable two steps authentication for a specific user


```
./manage.py two_factor_disable ${USERNAME}
```

### Public holidays

to import public holidays run:

```
./manage.py holidays ${YEARS}
```

where ${YEARS} should be a space separated list of years for which the holidays will be imported.

example:

```
./manage.py holidays 2017 2018 2019