forked from DGNum/gestioCOF
Migrations
Une migration pour les modèles, et une pour créer le groupe du Burô du BDS
This commit is contained in:
parent
bc7c30e2ee
commit
b3e7b59903
3 changed files with 172 additions and 0 deletions
141
bds/migrations/0001_initial.py
Normal file
141
bds/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,141 @@
|
|||
# Generated by Django 2.2 on 2019-07-17 12:48
|
||||
|
||||
import bds.models
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="BDSProfile",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"phone",
|
||||
models.CharField(
|
||||
blank=True, max_length=20, verbose_name="Téléphone"
|
||||
),
|
||||
),
|
||||
(
|
||||
"occupation",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("EXT", "Extérieur"),
|
||||
("1A", "1A"),
|
||||
("2A", "2A"),
|
||||
("3A", "3A"),
|
||||
("4A", "4A"),
|
||||
("MAG", "Magistérien"),
|
||||
("ARC", "Archicube"),
|
||||
("DOC", "Doctorant"),
|
||||
("CST", "CST"),
|
||||
("PER", "Personnel ENS"),
|
||||
],
|
||||
default="1A",
|
||||
max_length=3,
|
||||
verbose_name="Occupation",
|
||||
),
|
||||
),
|
||||
(
|
||||
"departement",
|
||||
models.CharField(
|
||||
blank=True, max_length=50, verbose_name="Département"
|
||||
),
|
||||
),
|
||||
(
|
||||
"birthdate",
|
||||
models.DateField(
|
||||
blank=True, null=True, verbose_name="Date de naissance"
|
||||
),
|
||||
),
|
||||
(
|
||||
"mails_bds",
|
||||
models.BooleanField(
|
||||
default=False, verbose_name="Recevoir les mails du BDS"
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_buro",
|
||||
models.BooleanField(
|
||||
default=False, verbose_name="Membre du Burô du BDS"
|
||||
),
|
||||
),
|
||||
(
|
||||
"has_certificate",
|
||||
models.BooleanField(
|
||||
default=False, verbose_name="Certificat médical"
|
||||
),
|
||||
),
|
||||
(
|
||||
"certificate_file",
|
||||
models.FileField(
|
||||
blank=True,
|
||||
upload_to=bds.models.BDSProfile.get_certificate_filename,
|
||||
verbose_name="Fichier de certificat médical",
|
||||
),
|
||||
),
|
||||
(
|
||||
"ASPSL_number",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
max_length=50,
|
||||
null=True,
|
||||
verbose_name="Numéro AS PSL",
|
||||
),
|
||||
),
|
||||
(
|
||||
"FFSU_number",
|
||||
models.CharField(
|
||||
blank=True, max_length=50, null=True, verbose_name="Numéro FFSU"
|
||||
),
|
||||
),
|
||||
(
|
||||
"cotisation_period",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("ANN", "Année"),
|
||||
("SE1", "Premier semestre"),
|
||||
("SE2", "Deuxième semestre"),
|
||||
("NO", "Aucune"),
|
||||
],
|
||||
default="NO",
|
||||
max_length=3,
|
||||
verbose_name="Inscription",
|
||||
),
|
||||
),
|
||||
(
|
||||
"registration_date",
|
||||
models.DateField(
|
||||
auto_now_add=True, verbose_name="Date d'inscription"
|
||||
),
|
||||
),
|
||||
(
|
||||
"user",
|
||||
models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="bds",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Profil BDS",
|
||||
"verbose_name_plural": "Profils BDS",
|
||||
},
|
||||
)
|
||||
]
|
30
bds/migrations/0002_bds_group.py
Normal file
30
bds/migrations/0002_bds_group.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 2.2 on 2019-07-17 14:56
|
||||
|
||||
from django.contrib.auth.management import create_permissions
|
||||
from django.db import migrations
|
||||
from django.db.models import Q
|
||||
|
||||
|
||||
def create_bds_buro_group(apps, schema_editor):
|
||||
for app_config in apps.get_app_configs():
|
||||
create_permissions(app_config, apps=apps, verbosity=0)
|
||||
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Permission = apps.get_model("auth", "Permission")
|
||||
group, created = Group.objects.get_or_create(name="Burô du BDS")
|
||||
if created:
|
||||
perms = Permission.objects.filter(
|
||||
Q(content_type__app_label="bds")
|
||||
| Q(content_type__app_label="auth") & Q(content_type__model="user")
|
||||
)
|
||||
group.permissions.set(perms)
|
||||
group.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("bds", "0001_initial")]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(create_bds_buro_group, migrations.RunPython.noop)
|
||||
]
|
|
@ -103,6 +103,7 @@ INSTALLED_APPS = [
|
|||
"kfet.auth",
|
||||
"kfet.cms",
|
||||
"gestioncof.cms",
|
||||
"bds",
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue