SMart SCHeduling
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
python manage.py superworker
Required software (on ubuntu's OS family):
- install required dependencies on ubuntu
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
- install nodejs
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install nodejs
Developer project installation
- clone smasch:
git clone ssh://git@git-r3lab-server.uni.lu:8022/NCER-PD/scheduling-system.git
- setup virtualenv with clean python3 working environment and start using it. Important python3.6 or higher is required
cd scheduling-system
virtualenv env -p python3
. env/bin/activate
- install smasch dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
npm install
- Create
local_settings.py
file insmash/smash
directory by copying the template insmash/smash/local_settings.template
and edit your local_setttings.py file to setFORCE_2FA = False
and change your database connection data.
Database configuration
There are two databases supported: sqlite3
or postgresql
. You can configure database connection in smash/smash/local_settings.py
.
- sqlite3 database configuration looks like:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
}
}
- postgresql database configuration looks like:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'smaschdb',
'USER': 'smaschuser',
'PASSWORD': 'smaschpassword',
'HOST': 'localhost',
'PORT': '',
'TEST': {
'NAME': 'dbtest',
},
}
}
After database connection is configured setup a database by applying migration scripts and create admin user
./manage.py migrate
./manage.py superworker -u admin -e test@test.lu -f John -l Doe
Development
Remember, that before working you have to activate virtualenv (in project directory), by:
. env/bin/activate
To add dummy data, run:
python smash/db_scripts/create_dummy_data.py
In order to run development server, run:
cd smash
./manage.py runserver
and go to 127.0.0.1:8000
in browser
Mac Developers
In case of problems with the openssl version installed on the system:
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
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
After smasch is installed you can start/stop it using systemd:
service smasch start
service smasch stop
Smasch service will be listening on port 8888 - go to http://localhost:8888/. By default smasch will use sqlite3 database.
Configuration of smasch (local_settings.py
) is in /etc/smasch/smasch.py
.
Operations
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