Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description and settings for a dev setup #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Shiftings

This is a simple shift management system. Built and maintained by students from the self-governed student dormatory [HaDiKo](https://www.hadiko.de/).
This is a simple shift management system. Built and maintained by students from the self-governed student dormitory [HaDiKo](https://www.hadiko.de/).

## Description

Expand All @@ -13,21 +13,84 @@ We plan on adding functionality for managing a high density of Shifts in a short

## Getting Started

### Requirements
### Development / Local setup

* Python >= 3.9
* Gunicorn or similar WSGI/ASGI Server
This section describes a quick local setup for development or testing out the software running and getting accessed on a single PC.

### Installing
#### Clone the repository

See [django docs](https://docs.djangoproject.com/en/4.1/howto/deployment/) for details on how to deploy a django application.
Start by cloning the repository and change your working directory to it:

```shell
git clone https://github.com/HaDiNet/shiftings
cd shiftings
```

#### Install dependencies

This software depends on python and its package index. The pip dependencies are listed in [pyproject.toml](pyproject.toml).

##### Manage dependencies using venv

You can manage your (virtual) python environment for this project using [venv](https://repology.org/project/python%3Avirtualenv/packages) and [pip](https://repology.org/project/python%3Apip/packages).
Make sure they are installed on your system and run the following setup commands:

```shell
python -m venv venv
source venv/bin/activate # Linux, BSD, MacOS
# venv\Scripts\activate # Windows
pip install .
```

Make sure to activate your venv (second line above) in every shell you want to interact with your venv. Some IDEs do this automatically for you.

By running `src/manage.py` you can [run Django commands and do administration](https://docs.djangoproject.com/en/5.1/ref/django-admin/).

#### Local settings

The [project settings](src/shiftings/settings.py) are already setup for development mode (`DEBUG = True`). Feel free to have a look at the settings or adapt them to your needs. If you just want to try out the software, no action is required.

#### Database setup

The script [setup_db.sh](setup_db.sh) initializes your database with the schema matching the shiftings models (running `manage.py migrate`) and [loading the fixtures](https://docs.djangoproject.com/en/5.1/howto/initial-data/) providing example data. Execute it for having a local database:

```shell
sh setup_db.sh
```

#### Development server

Django provides a simple development server supporting live reload on code change. You can run it with the following command:

```shell
python src/manage.py runserver
```

After that you can access your local shiftings instance at <http://127.0.0.1:8000/>.

#### User fixtures

In development mode you can switch between the pre-defined user fixtures with a button in the context menu at the top right of the web page or you can login using the lower case name as username and password (`bob`, `perry` etc.). **Bob** is a superuser and has access to the [Django admin page](http://127.0.0.1:8000/admin/) and **Perry** is a staff member. The other users have [different access to the first example organization](http://127.0.0.1:8000/organizations/1/admin/) provided by the fixture. Follow the provided links for more info.

#### Upgrade Django version

View the [Django documentation for upgrading Django projects](https://docs.djangoproject.com/en/5.1/howto/upgrade-version/). After switching to an newer version, make sure there are no warnings or errors by running

```shell
python -W all src/manage.py check --deploy
```

### Deployment / Shared setup

This section describes a shared setup deployed on a server for common use in an organization.

See [Django docs](https://docs.djangoproject.com/en/4.1/howto/deployment/) for details on how to deploy a Django application.

1. Clone the repository
1. Configure your WSGI Server
1. Add a local_settings.py. See local_settings.sample.py for inspiration.
1. Add a cron, systemd timer unit or similar for recurring shift creation


## Authors

[lewellien](https://github.com/lewellien) & [Tjeri](https://github.com/tjeri)
Expand Down
2 changes: 1 addition & 1 deletion src/shiftings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
FEATURES = {
'event': False, # enable events for organizations
'registration': True, # enable local registration
'gdpr_template': None # add a template for gpdr compliancy information
'gdpr_template': 'local/gdpr_template.sample.html' # add a template for gpdr compliancy information
}

MIDDLEWARE = [
Expand Down
34 changes: 34 additions & 0 deletions src/shiftings/templates/local/gdpr_template.sample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div>
<div>
<a href="#datenschutzModal" data-bs-toggle="modal" role="button" class="link">
Durch das Einloggen/Registrieren stimmst du der Verarbeitung deiner personenbezogenen Daten zu.<br>
(Klick hier für Details)
<hr>
By logging in/registering, you consent to the processing of your personal data.<br>
(click here for details)

</a>
</div>
<div class="modal fade text-start" id="datenschutzModal" tabindex="-1" aria-labelledby="{{ modal_id }}ModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" style="--bs-modal-width: 80vmin">
<div class="modal-content bg-dark border-success border-2">
<div class="modal-header">
<h5 class="modal-title" id="{{ modal_id }}Label">
Datenschutzerklärung / Terms of privacy
</h5>
<button type="button" class="btn btn-secondary btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div>
<h1>Privacy</h1>
<h2>Very important terms of privacy not so important for a dev setup</h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
</div>