1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-11-27 15:33:03 +00:00
med/README.md

133 lines
3.9 KiB
Markdown
Raw Normal View History

2019-08-02 11:17:36 +00:00
# Site de la Mediatek
2019-08-02 11:24:26 +00:00
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.txt)
[![pipeline status](https://gitlab.crans.org/mediatek/med/badges/master/pipeline.svg)](https://gitlab.crans.org/mediatek/med/commits/master)
[![coverage report](https://gitlab.crans.org/mediatek/med/badges/master/coverage.svg)](https://gitlab.crans.org/mediatek/med/commits/master)
2019-08-02 11:17:36 +00:00
Le projet Med permet la gestion de la base de donnée de la médiathèque de l'ENS Paris-Saclay.
Elle permet de gérer les medias, bd, jeux, emprunts, ainsi que les adhérents de la med.
2019-08-02 11:17:36 +00:00
## Licence
2019-08-10 06:04:46 +00:00
Ce projet est sous la licence GNU public license v3.0.
2017-07-03 23:53:23 +00:00
2020-02-09 13:18:39 +00:00
## Installation
2020-02-09 13:18:39 +00:00
### Développement
On peut soit développer avec Docker, soit utiliser un VirtualEnv.
Dans le cas du VirtualEnv,
2019-08-02 11:17:36 +00:00
```bash
2020-02-09 13:18:39 +00:00
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
2020-02-09 14:08:27 +00:00
./manage.py compilemessages
./manage.py makemigrations
2019-08-02 11:17:36 +00:00
./manage.py migrate
./manage.py runserver
```
2020-02-09 13:18:39 +00:00
### Production
Vous pouvez soit utiliser Docker, soit configurer manuellement le serveur.
#### Mise en place du projet sur Zamok
Pour mettre en place le projet sans droits root,
on va créer un socket uwsgi dans le répertoire personnel de l'utilisateur `club-med`
puis on va dire à Apache2 d'utiliser ce socket avec un `.htaccess`.
```bash
2020-02-09 14:26:34 +00:00
git clone https://gitlab.crans.org/mediatek/med.git django-med
chmod go-rwx -R django-med
2020-09-23 16:00:05 +00:00
python3 -m venv venv --system-site-packages
2020-02-09 13:18:39 +00:00
. venv/bin/activate
pip install -r requirements.txt
2020-12-28 21:59:54 +00:00
pip install mysqlclient~=1.4.4 # si base MySQL
2020-09-23 18:47:24 +00:00
pip install uwsgi~=2.0.18 # si production
2020-09-23 16:00:05 +00:00
./entrypoint.sh # lance en shell
2020-02-09 14:26:34 +00:00
```
2020-09-23 16:00:05 +00:00
Pour lancer le serveur au démarrage de Zamok, on suit les instructions dans `django-med.service`.
2020-02-09 14:45:49 +00:00
2020-02-09 15:02:19 +00:00
Pour reverse-proxyfier le serveur derrière Apache, on place dans `~/www/.htaccess` :
```apache
RewriteEngine On
2020-02-09 20:47:24 +00:00
# UWSGI socket
RewriteRule ^django.wsgi/(.*)$ unix:/home/c/club-med/django-med/uwsgi.sock|fcgi://localhost/ [P,NE,L]
# When not a file and not starting with django.wsgi, then forward to UWSGI
RewriteCond %{REQUEST_URI} !^/django.wsgi/
2020-02-09 15:14:47 +00:00
RewriteCond %{REQUEST_FILENAME} !-f
2020-02-09 20:47:24 +00:00
RewriteRule ^(.*)$ /django.wsgi/$1 [QSA,L]
2020-02-09 15:02:19 +00:00
```
2020-02-09 14:26:34 +00:00
Il est néanmoins une mauvaise idée de faire de la production sur SQLite,
on configure donc ensuite Django et une base de données.
2020-02-09 13:18:39 +00:00
#### Configuration d'une base de données
2020-02-09 13:18:39 +00:00
Sur le serveur MySQL ou PostgreSQL, il est nécessaire de créer une base de donnée med,
2019-08-02 11:17:36 +00:00
ainsi qu'un user med et un mot de passe associé.
2020-02-09 16:30:13 +00:00
Voici les étapes à executer pour PostgreSQL :
2019-08-02 11:17:36 +00:00
```SQL
2020-02-09 16:30:13 +00:00
CREATE DATABASE "club-med";
CREATE USER "club-med" WITH PASSWORD 'MY-STRONG-PASSWORD';
GRANT ALL PRIVILEGES ON DATABASE "club-med" TO "club-med";
2020-02-02 22:55:35 +00:00
```
2019-08-09 06:28:57 +00:00
## Exemple de groupes de droits
```
bureau
2019-08-16 13:05:10 +00:00
media | Can view borrowed item
media | Can add borrowed item
media | Can change borrowed item
media | Can delete borrowed item
users | Can view adhesion
users | Can add adhesion
users | Can change adhesion
users | Can delete adhesion
users | Can view user
users | Can add user
users | Can change user
sporz | Can view gamesave
+ permissions keyholder
2019-08-09 06:28:57 +00:00
keyholder
2019-08-16 13:19:55 +00:00
media | Can view author
media | Can add author
media | Can change author
media | Can delete author
media | Can view medium
media | Can add medium
media | Can change medium
media | Can delete medium
media | Can view game
media | Can add game
media | Can change game
media | Can delete game
media | Can view borrowed item
media | Can add borrowed item
media | Can change borrowed item
media | Can delete borrowed item
2019-08-16 13:05:10 +00:00
users | Can view user
2019-08-10 08:44:17 +00:00
2019-08-16 13:05:10 +00:00
users (default group for everyone)
2019-08-16 13:19:55 +00:00
media | Can view author
media | Can view game
media | Can view medium
2019-08-16 13:05:10 +00:00
sporz | Can add gamesave
sporz | Can change gamesave
sporz | Can add player
sporz | Can change player
sporz | Can delete player
2019-08-16 13:19:55 +00:00
sporz | Can view player
2019-08-09 06:28:57 +00:00
```