Merge branch 'initial_fixtures' into 'master'

Initial fixtures

See merge request bde/nk20!13
This commit is contained in:
Pierre-antoine Comby 2020-02-22 22:00:36 +01:00
commit c8dd41c1d7
6 changed files with 293 additions and 25 deletions

View File

@ -40,7 +40,7 @@ On supposera pour la suite que vous utiliser debian/ubuntu sur un serveur tout n
$ cp nginx_note.conf_example nginx_note.conf $ cp nginx_note.conf_example nginx_note.conf
*** Modifier le fichier pour etre en accord avec le reste de votre config *** ***Modifier le fichier pour être en accord avec le reste de votre config***
On utilise uwsgi et Nginx pour gérer le coté serveu : On utilise uwsgi et Nginx pour gérer le coté serveu :
@ -107,10 +107,9 @@ On supposera pour la suite que vous utiliser debian/ubuntu sur un serveur tout n
6. Variable d'environnement et Migrations 6. Variable d'environnement et Migrations
Ensuite on (re)bascule dans l'environement virtuel et on lance les migrations Ensuite on (re)bascule dans l'environement virtuel et on lance les migrations
$ source /env/bin/activate $ source /env/bin/activate
(env)$ ./manage.py check # pas de bétise qui traine (env)$ ./manage.py check # pas de bétise qui traine
(env)$ ./manage.py makemigrations (env)$ ./manage.py makemigrations
@ -127,7 +126,8 @@ Il est possible de travailler sur une instance Docker.
$ git clone git@gitlab.crans.org:bde/nk20.git $ git clone git@gitlab.crans.org:bde/nk20.git
2. Dans le fichier `docker_compose.yml`, qu'on suppose déjà configuré, ajouter les lignes suivantes, en les adaptant à la configuration voulue : 2. Dans le fichier `docker_compose.yml`, qu'on suppose déjà configuré,
ajouter les lignes suivantes, en les adaptant à la configuration voulue :
nk20: nk20:
build: /chemin/vers/nk20 build: /chemin/vers/nk20
@ -143,38 +143,39 @@ Il est possible de travailler sur une instance Docker.
$ docker-compose up -d nk20 $ docker-compose up -d nk20
## Installer en local ## Installer un serveur de développement
Il est tout-à-fait possible de travailler en local, vive `./manage.py runserver` ! Avec `./manage.py runserver` il est très rapide de mettre en place
un serveur de développement par exemple sur son ordinateur.
1. Cloner le dépôt là où vous voulez : 1. Cloner le dépôt là où vous voulez :
$ git clone git@gitlab.crans.org:bde/nk20.git $ git clone git@gitlab.crans.org:bde/nk20.git && cd nk20
2. Initialiser l'environnement Virtuel 2. Créer un environnement Python isolé
pour ne pas interférer avec les versions de paquets systèmes :
$ cd nk20
$ virtualenv env $ python3 -m venv venv
$ source /env/bin/activate $ source venv/bin/activate
(env)$ pip install -r requirements.txt (env)$ pip install -r requirements.txt
3. Migrations: 3. Migrations et chargement des données initiales :
(env)$ ./manage.py makemigrations (env)$ ./manage.py makemigrations
(env)$ ./manage.py migrate (env)$ ./manage.py migrate
(env)$ ./manage.py loaddata initial
4. Enjoy: 4. Créer un super-utilisateur :
(env)$ ./manage.py runserver
## Minimal Setup
1. Créer un superuser :
(env)$ ./manage.py createsuperuser (env)$ ./manage.py createsuperuser
Avec ce dernier vous pouvez vous connecter à l'interface admin de Django, avoir 5. Enjoy :
accès à la doc auto-générée du projet, jouer avec des models, etc ...
(env)$ ./manage.py runserver 0.0.0.0:8000
En mettant `0.0.0.0:8000` après `runserver`, vous rendez votre instance Django
accessible depuis l'ensemble de votre réseau, pratique pour tester le rendu
de la note sur un téléphone !
## Cahier des Charges ## Cahier des Charges
@ -182,4 +183,5 @@ Il est disponible [ici](https://wiki.crans.org/NoteKfet/NoteKfet2018/CdC).
## Documentation ## Documentation
La documentation est générée par django et son module admindocs. **Commenter votre code !* La documentation est générée par django et son module admindocs.
**Commenter votre code !**

View File

@ -0,0 +1,26 @@
[
{
"model": "member.club",
"pk": 1,
"fields": {
"name": "BDE",
"email": "tresorerie.bde@example.com",
"membership_fee": 5,
"membership_duration": "396 00:00:00",
"membership_start": "213 00:00:00",
"membership_end": "273 00:00:00"
}
},
{
"model": "member.club",
"pk": 2,
"fields": {
"name": "Kfet",
"email": "tresorerie.bde@example.com",
"membership_fee": 35,
"membership_duration": "396 00:00:00",
"membership_start": "213 00:00:00",
"membership_end": "273 00:00:00"
}
}
]

View File

@ -0,0 +1,220 @@
[
{
"model": "note.note",
"pk": 1,
"fields": {
"polymorphic_ctype": 22,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:02:48.778Z"
}
},
{
"model": "note.note",
"pk": 2,
"fields": {
"polymorphic_ctype": 22,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:06:39.546Z"
}
},
{
"model": "note.note",
"pk": 3,
"fields": {
"polymorphic_ctype": 22,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:06:43.049Z"
}
},
{
"model": "note.note",
"pk": 4,
"fields": {
"polymorphic_ctype": 22,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:06:50.996Z"
}
},
{
"model": "note.note",
"pk": 5,
"fields": {
"polymorphic_ctype": 21,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:09:38.615Z"
}
},
{
"model": "note.note",
"pk": 6,
"fields": {
"polymorphic_ctype": 21,
"balance": 0,
"is_active": true,
"display_image": "",
"created_at": "2020-02-20T20:16:14.753Z"
}
},
{
"model": "note.notespecial",
"pk": 1,
"fields": {
"special_type": "Esp\u00e8ces"
}
},
{
"model": "note.notespecial",
"pk": 2,
"fields": {
"special_type": "Carte bancaire"
}
},
{
"model": "note.notespecial",
"pk": 3,
"fields": {
"special_type": "Ch\u00e8que"
}
},
{
"model": "note.notespecial",
"pk": 4,
"fields": {
"special_type": "Virement bancaire"
}
},
{
"model": "note.noteclub",
"pk": 5,
"fields": {
"club": 1
}
},
{
"model": "note.noteclub",
"pk": 6,
"fields": {
"club": 2
}
},
{
"model": "note.alias",
"pk": 1,
"fields": {
"name": "Esp\u00e8ces",
"normalized_name": "especes",
"note": 1
}
},
{
"model": "note.alias",
"pk": 2,
"fields": {
"name": "Carte bancaire",
"normalized_name": "cartebancaire",
"note": 2
}
},
{
"model": "note.alias",
"pk": 3,
"fields": {
"name": "Ch\u00e8que",
"normalized_name": "cheque",
"note": 3
}
},
{
"model": "note.alias",
"pk": 4,
"fields": {
"name": "Virement bancaire",
"normalized_name": "virementbancaire",
"note": 4
}
},
{
"model": "note.alias",
"pk": 5,
"fields": {
"name": "BDE",
"normalized_name": "bde",
"note": 5
}
},
{
"model": "note.alias",
"pk": 6,
"fields": {
"name": "Kfet",
"normalized_name": "kfet",
"note": 6
}
},
{
"model": "note.transactioncategory",
"pk": 1,
"fields": {
"name": "Soft"
}
},
{
"model": "note.transactioncategory",
"pk": 2,
"fields": {
"name": "Pulls"
}
},
{
"model": "note.transactioncategory",
"pk": 3,
"fields": {
"name": "Gala"
}
},
{
"model": "note.transactioncategory",
"pk": 4,
"fields": {
"name": "Clubs"
}
},
{
"model": "note.transactioncategory",
"pk": 5,
"fields": {
"name": "Bouffe"
}
},
{
"model": "note.transactioncategory",
"pk": 6,
"fields": {
"name": "BDA"
}
},
{
"model": "note.transactioncategory",
"pk": 7,
"fields": {
"name": "Autre"
}
},
{
"model": "note.transactioncategory",
"pk": 8,
"fields": {
"name": "Alcool"
}
}
]

View File

@ -2,20 +2,28 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
def save_user_note(instance, created, **_kwargs): def save_user_note(instance, created, raw, **_kwargs):
""" """
Hook to create and save a note when an user is updated Hook to create and save a note when an user is updated
""" """
if raw:
# When provisionning data, do not try to autocreate
return
if created: if created:
from .models import NoteUser from .models import NoteUser
NoteUser.objects.create(user=instance) NoteUser.objects.create(user=instance)
instance.note.save() instance.note.save()
def save_club_note(instance, created, **_kwargs): def save_club_note(instance, created, raw, **_kwargs):
""" """
Hook to create and save a note when a club is updated Hook to create and save a note when a club is updated
""" """
if raw:
# When provisionning data, do not try to autocreate
return
if created: if created:
from .models import NoteClub from .models import NoteClub
NoteClub.objects.create(club=instance) NoteClub.objects.create(club=instance)

View File

@ -0,0 +1,10 @@
[
{
"model": "sites.site",
"pk": 1,
"fields": {
"domain": "localhost",
"name": "La Note Kfet \ud83c\udf7b"
}
}
]

View File

@ -161,6 +161,8 @@ USE_TZ = True
LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")] LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")]
FIXTURE_DIRS = [os.path.join(BASE_DIR, "note_kfet/fixtures")]
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/ # https://docs.djangoproject.com/en/2.2/howto/static-files/