Skip to content

Commit

Permalink
Merge pull request #60 from DataManagementLab/integration
Browse files Browse the repository at this point in the history
Integration of lab changes
  • Loading branch information
bhaettasch authored Jul 9, 2021
2 parents df4d46d + c2fa0f1 commit dd15242
Show file tree
Hide file tree
Showing 228 changed files with 14,713 additions and 1,647 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [ 3.7, 3.8 ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py check
python manage.py test
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install LaTeX/PDF Dependencies
run: |
sudo apt-get install texlive-full
sudo apt-get install poppler-utils
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py check
python manage.py test
44 changes: 44 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PyLint Django

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [ 3.7, 3.8 ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install pylint-django
pip install -r requirements.txt
- name: Run PyLint - base
run: |
pylint --fail-under=9 --load-plugins=pylint_django --django-settings-module=collab_coursebook.settings base
- name: Run PyLint - content
run: |
pylint --fail-under=9 --load-plugins=pylint_django --django-settings-module=collab_coursebook.settings content
- name: Run PyLint - export
run: |
pylint --fail-under=9 --load-plugins=pylint_django --django-settings-module=collab_coursebook.settings export
- name: Run PyLint - frontend
run: |
pylint --fail-under=9 --load-plugins=pylint_django --django-settings-module=collab_coursebook.settings frontend
- name: Run PyLint - test
run: |
pylint --fail-under=9 --load-plugins=pylint_django --django-settings-module=collab_coursebook.settings test
106 changes: 66 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

Collab Coursebook is a plattform for collaborative learning und knowledge organization. It provides a place to share and re-use notes and other learning materials.
Collab Coursebook is a platform for collaborative learning und knowledge organization. It provides a place to share and re-use notes and other learning materials.

## Setup

Expand All @@ -13,50 +13,55 @@ This repository contains a Django project with several apps.

### Requirements

Collab Coursebook has two types of requirements: System requirements are dependent on operating system and need to be installed manually beforehand. Python requirements will be installed inside a virtual environment (strongly recommended) during setup.
Collab Coursebook has two types of requirements: System requirements are dependent on operating system and need to be installed manually beforehand. Python requirements will be installed inside a virtual environment (strongly recommended) during a setup.


#### System Requirements

* Python 3.6 incl. development tools
* Python 3.7 incl. development tools
* Virtualenv
* poppler
* for production using uwsgi:
* TeX Distribution (e.g. TeX Live)
* For production using uwsgi:
* C compiler e.g. gcc
* uwsgi
* uwsgi Python3 plugin
* for production using Apache (in addition to uwsgi)
* For production using Apache (in addition to uwsgi)
* the mod proxy uwsgi plugin for apache2


#### Python Requirements

Python requirements are listed in ``requirements.txt``. They can be installed with pip using ``-r requirements.txt``.


#### Distributable Setup

* In order to use Nestable2 correctly the dist folder is needed. This folder can be found here: https://github.com/RamonSmit/Nestable2
* The folder must be placed in `frontend/static/vendor/Nestable2`.
### Development Setup

* create a new directory that should contain the files in future, e.g. ``mkdir collab-coursebook``
* change into that directory ``cd collab-coursebook``
* clone this repository ``git clone URL .``
* Create a new directory that should contain the files in the future, e.g. ``mkdir collab-coursebook``
* Change into that directory ``cd collab-coursebook``
* Clone this repository ``git clone URL .``


**Automatic Setup**
#### Linux

1. execute the setup bash script ``Utils/setup.sh``
**Automatic Setup**

1. Execute the setup bash script ``utils/setup.sh``

**Manual Setup**

1. setup a virtual environment using the proper python version ``virtualenv venv -p python3``
1. activate virtualenv ``source venv/bin/activate``
1. install python requirements ``pip install -r requirements.txt``
1. setup necessary database tables etc. ``python manage.py migrate``
1. prepare static files (can be omitted for dev setups) ``python manage.py collectstatic``
1. compile translations ``python manage.py compilemessages``
1. create a priviledged user, credentials are entered interactively on CLI ``python manage.py createsuperuser``
1. deactivate virtualenv ``deactivate``

1. Set up a virtual environment using the proper python version ``virtualenv venv -p python3``
1. Activate virtualenv ``source venv/bin/activate``
1. Install python requirements ``pip install -r requirements.txt``
1. Set up necessary database tables etc. ``python manage.py migrate``
1. Setup initial revision for all registered models for versioning``python manage.py createinitialrevisions``
1. Prepare static files (can be omitted for dev setups) ``python manage.py collectstatic``
1. Compile translations ``python manage.py compilemessages``
1. Create a privileged user, credentials are entered interactively on CLI ``python manage.py createsuperuser``
1. Deactivate virtualenv ``deactivate``

**Development Server**

Expand All @@ -65,6 +70,27 @@ To start the application for development use ``python manage.py runserver 0:8000

In your browser, access ``http://127.0.0.1:8000/`` and continue from there.

#### Windows

**Manual Setup**

1. Set up a virtual environment using the proper python version ``virtualenv venv -p python3``
1. Activate virtualenv `.\venv\Scripts\activate`
1. Install python requirements ``pip install -r requirements.txt``
1. Install python magic-bin ``pip install python-magic-bin``
1. Set up necessary database tables etc. ``python manage.py migrate``
1. Setup initial revision for all registered models for versioning``python manage.py createinitialrevisions``
1. Prepare static files (can be omitted for dev setups) ``python manage.py collectstatic``
1. Compile translations ``python manage.py compilemessages``
1. Create a privileged user, credentials are entered interactively on CLI ``python manage.py createsuperuser``
1. Deactivate virtualenv ``deactivate``

**Development Server**

To start the application for development use ``python manage.py runserver 0.0.0.0:8000`` from the root directory.
*Do not use this for deployment!*

In your browser, access ``http://127.0.0.1:8000/`` and continue from there.

### Deployment Setup

Expand All @@ -73,18 +99,18 @@ Remember to use a secret key that is not stored in any repository or similar, an

**Step-by-Step Instructions**

1. log into your system with a sudo user
1. install system requirements
1. create a folder, e.g. ``mkdir /srv/collab-coursebook/``
1. change to the new directory ``cd /srv/collab-coursebook/``
1. clone this repository ``git clone URL .``
1. setup a virtual environment using the proper python version ``virtualenv venv -p python3``
1. activate virtualenv ``source venv/bin/activate``
1. update tools ``pip install --upgrade setuptools pip wheel``
1. install python requirements ``pip install -r requirements.txt``
1. create the file ``collab_coursebook/settings_secrets.py`` (copy from ``settings_secrets.py.sample``) and fill it with the necessary secrets (e.g. generated by ``tr -dc 'a-z0-9!@#$%^&*(-_=+)' < /dev/urandom | head -c50``) (it is a good idea to restrict read permissions from others)
1. if necessary enable uwsgi proxy plugin for Apache e.g.``a2enmod proxy_uwsgi``
1. edit the apache config to serve the application and the static files, e.g. on a dedicated system in ``/etc/apache2/sites-enabled/000-default.conf`` within the ``VirtualHost`` tag add:
1. Log into your system with a sudo user
1. Install system requirements
1. Create a folder, e.g. ``mkdir /srv/collab-coursebook/``
1. Change to the new directory ``cd /srv/collab-coursebook/``
1. Clone this repository ``git clone URL .``
1. Set up a virtual environment using the proper python version ``virtualenv venv -p python3``
1. Activate virtualenv ``source venv/bin/activate``
1. Update tools ``pip install --upgrade setuptools pip wheel``
1. Install python requirements ``pip install -r requirements.txt``
1. Create the file ``collab_coursebook/settings_secrets.py`` (copy from ``settings_secrets.py.sample``) and fill it with the necessary secrets (e.g. generated by ``tr -dc 'a-z0-9!@#$%^&*(-_=+)' < /dev/urandom | head -c50``) (it is a good idea to restrict read permissions from others)
1. If necessary enable uwsgi proxy plugin for Apache e.g.``a2enmod proxy_uwsgi``
1. Edit the apache config to serve the application and the static files, e.g. on a dedicated system in ``/etc/apache2/sites-enabled/000-default.conf`` within the ``VirtualHost`` tag add:

```
Alias /static /srv/collab-coursebook/static
Expand All @@ -99,13 +125,13 @@ Remember to use a secret key that is not stored in any repository or similar, an
or create a new config (.conf) file (similar to ``apache-collab-coursebook.conf``) replacing $SUBDOMAIN with the subdomain the system should be available under, and $MAILADDRESS with the e-mail address of your administrator and $PATHTO with the appropriate paths. Copy or symlink it to ``/etc/apache2/sites-available``. Then activate it with ``a2ensite collab-coursebook``.
1. restart Apache ``sudo apachectl restart``
1. create a dedicated user, e.g. ``adduser django --disabled-login``
1. transfer ownership of the folder to the new user ``chown -R django:django /srv/collab-coursebook``
1. Restart Apache ``sudo apachectl restart``
1. Create a dedicated user, e.g. ``adduser django --disabled-login``
1. Transfer ownership of the folder to the new user ``chown -R django:django /srv/collab-coursebook``
1. Copy or symlink the uwsgi config in ``uwsgi-collab-coursebook.ini`` to ``/etc/uwsgi/apps-available/`` and then symlink it to ``/etc/uwsgi/apps-enabled/`` using e.g., ``ln -s /srv/collab-coursebook/uwsgi-collab-coursebook.ini /etc/uwsgi/apps-available/collab-coursebook.ini`` and ``ln -s /etc/uwsgi/apps-available/collab-coursebook.ini /etc/uwsgi/apps-enabled/collab-coursebook.ini``
1. test your uwsgi configuration file with``uwsgi --ini collab-coursebook.ini``
1. restart uwsgi ``sudo systemctl restart uwsgi``
1. execute the update script ``./Utils/update.sh --prod``
1. Test your uwsgi configuration file with``uwsgi --ini collab-coursebook.ini``
1. Restart uwsgi ``sudo systemctl restart uwsgi``
1. Execute the update script ``./utils/update.sh --prod``
### Updates
Expand All @@ -125,5 +151,5 @@ This repository contains a Django project called collab_coursebook. The function
1. **export**: This app contains export functions for the custom content collections (coursebooks).
## Developer Notes
* to regenerate translations use ````python manage.py makemessages -l de_DE --ignore venv````
* to create a data backup use ````python manage.py dumpdata --indent=2 > db.json --traceback````
* To regenerate translations use ````python manage.py makemessages -l de_DE --ignore venv````
* To create a data backup use ````python manage.py dumpdata --indent=2 > db.json --traceback````
5 changes: 5 additions & 0 deletions base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Init
Marks this directory as Python package directories. This package contains the base structure
of the collab coursebook.
"""
Loading

0 comments on commit dd15242

Please sign in to comment.