-
Piotr Gawron authoredPiotr Gawron authored
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, currently only python3.6-3.8 are supported
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
Release new version
- Create git tag (for example
v1.0.2
). This will trigger pipeline that will create deb package. - Login to LCSB repository
repo-r3lab.uni.lu
using ssh:
ssh 10.240.6.115 -p 8022
- Download deb package artifact from
build_debian
job. The url of deb package can be found by: Select tag (v1.0.2
)→Click hash (0c664f23
)→Pipelines→Stages;build:passed→build_debian→Job artifacts→Browse→smasch_1.0.2-1_all.deb→Download. Not sure how to do it easier. For example:
wget https://gitlab.lcsb.uni.lu/smasch/scheduling-system/-/jobs/282797/artifacts/raw/smasch_1.0.2-1_all.deb
- Put deb file in repository. The password is shared in lastpass note.
sudo reprepro -b /var/www/html/debian includedeb stable smasch_1.0.2-1_all.deb
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