Fix circular deps in the migrations
This commit is contained in:
parent
894c70149c
commit
e578aef74d
8 changed files with 307 additions and 501 deletions
|
@ -4,6 +4,15 @@ from __future__ import unicode_literals
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def create_groups(apps, schema_editor):
|
||||
"""
|
||||
Creates the groups for BDS members and staff
|
||||
"""
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Group.objects.get_or_create(name="bds_members")
|
||||
Group.objects.get_or_create(name="bds_buro")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
|
@ -22,4 +31,5 @@ class Migration(migrations.Migration):
|
|||
'verbose_name_plural': 'Profils BDS'
|
||||
},
|
||||
),
|
||||
migrations.RunPython(create_groups, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
|
@ -25,7 +25,7 @@ def create_profile(apps, schema_editor):
|
|||
def preserve_perms(apps, schema_editor):
|
||||
COFProfile = apps.get_model("cof", "CofProfile")
|
||||
|
||||
# creates the groups for COF members and
|
||||
# create the groups for COF members and staff
|
||||
member = Group.objects.create(name='cof_members')
|
||||
buro = Group.objects.create(name='cof_buro')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11b1 on 2017-03-18 20:02
|
||||
# Generated by Django 1.11.3 on 2017-07-26 18:29
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -10,8 +10,8 @@ import django.db.models.deletion
|
|||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("cof", "0012_remove_club"),
|
||||
("gestion", "0003_events"),
|
||||
('cof', '0012_remove_club'),
|
||||
("gestion", "0003_association_and_events")
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -58,37 +58,22 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='petitcoursattribution',
|
||||
name='matiere',
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='cof.PetitCoursSubject',
|
||||
verbose_name='Matière'
|
||||
),
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cof.PetitCoursSubject', verbose_name='Matière'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='petitcoursattributioncounter',
|
||||
name='matiere',
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to='cof.PetitCoursSubject',
|
||||
verbose_name='Matiere'
|
||||
),
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cof.PetitCoursSubject', verbose_name='Matiere'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='petitcoursattributioncounter',
|
||||
name='user',
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL
|
||||
),
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='petitcoursdemande',
|
||||
name='traitee_par',
|
||||
field=models.ForeignKey(
|
||||
blank=True, null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to=settings.AUTH_USER_MODEL
|
||||
),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Event',
|
||||
|
|
288
gestion/migrations/0003_association_and_events.py
Normal file
288
gestion/migrations/0003_association_and_events.py
Normal file
|
@ -0,0 +1,288 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.3 on 2017-07-26 18:29
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def create_apps(apps, schema_editor):
|
||||
Association = apps.get_model("gestion", "Association")
|
||||
Group = apps.get_model("auth", "Group")
|
||||
|
||||
cof_m = Group.objects.get(name="cof_members")
|
||||
cof_b = Group.objects.get(name="cof_buro")
|
||||
bds_m = Group.objects.get(name="bds_members")
|
||||
bds_b = Group.objects.get(name="bds_buro")
|
||||
|
||||
Association.objects.bulk_create([
|
||||
Association(name="COF", staff_group=cof_b, members_group=cof_m),
|
||||
Association(name="BDS", staff_group=bds_b, members_group=bds_m),
|
||||
])
|
||||
|
||||
|
||||
def import_events(apps, schema_editor):
|
||||
# Fetching the models that have be moved from cof to gestion
|
||||
model_names = [
|
||||
"Event", "EventCommentField", "EventCommentValue", "EventOption",
|
||||
"EventOptionChoice", "EventRegistration"
|
||||
]
|
||||
models = [
|
||||
(apps.get_model("cof", name), apps.get_model("gestion", name))
|
||||
for name in model_names
|
||||
]
|
||||
|
||||
# The old Event.location field becomes a table: we need to create an entry
|
||||
# in this table for each value of the old `location` field.
|
||||
OldEvent, NewEvent = models[0]
|
||||
Location = apps.get_model("gestion", "Location")
|
||||
locations = set() # A set to prevent duplicate entries
|
||||
events = []
|
||||
for event in OldEvent.objects.values():
|
||||
locations.add(event["location"])
|
||||
events.append(event)
|
||||
Location.objects.bulk_create([Location(name=name) for name in locations])
|
||||
map_loc = {
|
||||
loc.name: loc
|
||||
for loc in Location.objects.all()
|
||||
}
|
||||
for event in events:
|
||||
event["location"] = map_loc[event["location"]]
|
||||
NewEvent.objects.bulk_create([
|
||||
NewEvent(**event)
|
||||
for event in events
|
||||
])
|
||||
|
||||
# Do not forget to link all the existing event to the COF group
|
||||
cof = apps.get_model("gestion", "Association").objects.get(name="COF")
|
||||
for event in NewEvent.objects.all():
|
||||
event.associations.add(cof)
|
||||
|
||||
# Migrating the other models is straigtforward
|
||||
for OldModel, NewModel in models[1:]:
|
||||
NewModel.objects.bulk_create([
|
||||
NewModel(**values)
|
||||
for values in OldModel.objects.values()
|
||||
])
|
||||
|
||||
|
||||
def restore_events(apps, schema_editor):
|
||||
# TODO?
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('auth', '0008_alter_user_username_max_length'),
|
||||
('gestion', '0002_club_support'),
|
||||
("cof", "0009_generic_profiles"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Association',
|
||||
fields=[
|
||||
('name', models.CharField(max_length=30, primary_key=True, serialize=False, verbose_name="nom de l'association")),
|
||||
('members_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='member_groups', to='auth.Group', verbose_name='groupe des membres')),
|
||||
('staff_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='staff_groups', to='auth.Group', verbose_name='groupe des membre du bureau')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'association',
|
||||
'verbose_name_plural': 'associations',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Event',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200, verbose_name='titre')),
|
||||
('start_date', models.DateTimeField(blank=True, null=True, verbose_name="début de l'événement")),
|
||||
('end_date', models.DateTimeField(blank=True, null=True, verbose_name="fin de l'événement")),
|
||||
('description', models.TextField(blank=True, verbose_name='description')),
|
||||
('image', models.ImageField(blank=True, null=True, upload_to='public/imgs/events/', verbose_name='image')),
|
||||
('registration_open', models.BooleanField(default=True, verbose_name='les inscriptions sont ouvertes')),
|
||||
('old', models.BooleanField(default=False, verbose_name='archiver (événement fini)')),
|
||||
('associations', models.ManyToManyField(related_name='events', to='gestion.Association', verbose_name='associations')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'événement',
|
||||
'verbose_name_plural': 'événements',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventCommentField',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom du champ')),
|
||||
('fieldtype', models.CharField(choices=[('text', 'Texte long'), ('char', 'Texte court')], default='text', max_length=10, verbose_name='type de champ')),
|
||||
('default', models.TextField(blank=True, verbose_name='valeur par défaut')),
|
||||
('ordering', models.IntegerField(default=False, help_text='plus petit en premier, ordre alphabétique sur le nom si ambiguïté', verbose_name='ordre des champs')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commentfields', to='gestion.Event', verbose_name='événement')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'champ',
|
||||
'verbose_name_plural': 'champs',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventCommentValue',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content', models.TextField(blank=True, verbose_name='contenu')),
|
||||
('commentfield', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='values', to='gestion.EventCommentField')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventOption',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='option')),
|
||||
('multi_choices', models.BooleanField(default=False, verbose_name='choix multiples')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='gestion.Event', verbose_name='événement')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'option des événements',
|
||||
'verbose_name_plural': 'options des événements',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventOptionChoice',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('value', models.CharField(max_length=200, verbose_name='Valeur')),
|
||||
('event_option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='gestion.EventOption', verbose_name='événement')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'choix',
|
||||
'verbose_name_plural': 'choix',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventRegistration',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('paid', models.BooleanField(default=False, verbose_name='a payé')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gestion.Event', verbose_name='événement')),
|
||||
('filledcomments', models.ManyToManyField(through='gestion.EventCommentValue', to='gestion.EventCommentField', verbose_name='commentaires')),
|
||||
('options', models.ManyToManyField(to='gestion.EventOptionChoice', verbose_name='choix')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='utilisateur')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'inscription',
|
||||
'verbose_name_plural': 'inscriptions',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Location',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom du lieux')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'lieu',
|
||||
'verbose_name_plural': 'lieux',
|
||||
},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='profile',
|
||||
options={'verbose_name': 'profil', 'verbose_name_plural': 'profils'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='club',
|
||||
name='associations',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='cotisation_frequency',
|
||||
field=models.CharField(blank=True, choices=[('ANN', 'Annuel'), ('SEM', 'Semestriel'), ('COU', 'Au cours')], default='ANN', max_length=3, verbose_name='fréquence de la cotisation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, verbose_name='description'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='members',
|
||||
field=models.ManyToManyField(blank=True, related_name='in_clubs', through='gestion.ClubUser', to=settings.AUTH_USER_MODEL, verbose_name='membres du club'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, unique=True, verbose_name='nom'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='price',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=5, verbose_name='cotisation (€)'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clubuser',
|
||||
name='has_paid',
|
||||
field=models.BooleanField(verbose_name='a payé sa cotisation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clubuser',
|
||||
name='is_respo',
|
||||
field=models.BooleanField(verbose_name='est responsable du club'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='comments',
|
||||
field=models.TextField(blank=True, verbose_name="commentaires visibles par l'utilisateur"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='departement',
|
||||
field=models.CharField(blank=True, max_length=50, verbose_name='département'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='login_clipper',
|
||||
field=models.CharField(blank=True, max_length=8, verbose_name='login clipper'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='occupation',
|
||||
field=models.CharField(choices=[('exterieur', 'Extérieur'), ('1A', '1A'), ('2A', '2A'), ('3A', '3A'), ('4A', '4A'), ('archicube', 'Archicube'), ('doctorant', 'Doctorant'), ('CST', 'CST')], default='1A', max_length=9, verbose_name='occupation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='phone',
|
||||
field=models.CharField(blank=True, max_length=20, verbose_name='téléphone'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='user',
|
||||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL, verbose_name='utilisateur'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='eventcommentvalue',
|
||||
name='registration',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='gestion.EventRegistration'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='location',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='gestion.Location', verbose_name='lieux'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='club',
|
||||
name='association',
|
||||
field=models.ForeignKey(default='COF', on_delete=django.db.models.deletion.PROTECT, related_name='clubs', to='gestion.Association', verbose_name='association'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='eventregistration',
|
||||
unique_together=set([('user', 'event')]),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='eventcommentvalue',
|
||||
unique_together=set([('commentfield', 'registration')]),
|
||||
),
|
||||
migrations.RunPython(create_apps, migrations.RunPython.noop),
|
||||
migrations.RunPython(import_events, restore_events),
|
||||
]
|
|
@ -1,182 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11b1 on 2017-03-18 20:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def import_events(apps, schema_editor):
|
||||
# Fetching the models that have be moved from cof to gestion
|
||||
model_names = [
|
||||
"Event", "EventCommentField", "EventCommentValue", "EventOption",
|
||||
"EventOptionChoice", "EventRegistration"
|
||||
]
|
||||
models = [
|
||||
(apps.get_model("cof", name), apps.get_model("gestion", name))
|
||||
for name in model_names
|
||||
]
|
||||
|
||||
# The old Event.location field becomes a table: we need to create an entry
|
||||
# in this table for each value of the old `location` field.
|
||||
OldEvent, NewEvent = models[0]
|
||||
Location = apps.get_model("gestion", "Location")
|
||||
locations = set() # A set to prevent duplicate entries
|
||||
events = []
|
||||
for event in OldEvent.objects.values():
|
||||
locations.add(event["location"])
|
||||
events.append(event)
|
||||
Location.objects.bulk_create([Location(name=name) for name in locations])
|
||||
map_loc = {
|
||||
loc.name: loc
|
||||
for loc in Location.objects.all()
|
||||
}
|
||||
for event in events:
|
||||
event["location"] = map_loc[event["location"]]
|
||||
NewEvent.objects.bulk_create([
|
||||
NewEvent(**event)
|
||||
for event in events
|
||||
])
|
||||
|
||||
# Do not forget to link all the existing event to the COF group
|
||||
cof = apps.get_model("auth", "Group").objects.get(name="cof_buro")
|
||||
for event in NewEvent.objects.all():
|
||||
event.associations.add(cof)
|
||||
|
||||
# Migrating the other models is straigtforward
|
||||
for OldModel, NewModel in models[1:]:
|
||||
NewModel.objects.bulk_create([
|
||||
NewModel(**values)
|
||||
for values in OldModel.objects.values()
|
||||
])
|
||||
|
||||
|
||||
def restore_events(apps, schema_editor):
|
||||
# TODO?
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('auth', '0008_alter_user_username_max_length'),
|
||||
('gestion', '0002_club_support'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Location',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID'
|
||||
)
|
||||
),
|
||||
(
|
||||
'name',
|
||||
models.CharField(max_length=200, verbose_name='Lieu')
|
||||
),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'lieu',
|
||||
'verbose_name_plural': 'lieux',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Event',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200, verbose_name='Titre')),
|
||||
('location', models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to='gestion.Location'
|
||||
)),
|
||||
('start_date', models.DateTimeField(blank=True, null=True, verbose_name='Date de début')),
|
||||
('end_date', models.DateTimeField(blank=True, null=True, verbose_name='Date de fin')),
|
||||
('description', models.TextField(blank=True, verbose_name='Description')),
|
||||
('image', models.ImageField(blank=True, null=True, upload_to='imgs/events/', verbose_name='Image')),
|
||||
('registration_open', models.BooleanField(default=True, verbose_name='Inscriptions ouvertes')),
|
||||
('old', models.BooleanField(default=False, verbose_name='Archiver (événement fini)')),
|
||||
('associations', models.ManyToManyField(related_name='events', to='auth.Group')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Événement',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventCommentField',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='Champ')),
|
||||
('fieldtype', models.CharField(choices=[('text', 'Texte long'), ('char', 'Texte court')], default='text', max_length=10, verbose_name='Type')),
|
||||
('default', models.TextField(blank=True, verbose_name='Valeur par défaut')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commentfields', to='gestion.Event')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Champ',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventCommentValue',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content', models.TextField(blank=True, null=True, verbose_name='Contenu')),
|
||||
('commentfield', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='values', to='gestion.EventCommentField')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventOption',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='Option')),
|
||||
('multi_choices', models.BooleanField(default=False, verbose_name='Choix multiples')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='gestion.Event')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Option des événements',
|
||||
'verbose_name_plural': 'Options des événements'
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventOptionChoice',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('value', models.CharField(max_length=200, verbose_name='Valeur')),
|
||||
('event_option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='gestion.EventOption')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Choix',
|
||||
'verbose_name': 'Choix',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EventRegistration',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('paid', models.BooleanField(default=False, verbose_name='A payé')),
|
||||
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gestion.Event')),
|
||||
('filledcomments', models.ManyToManyField(through='gestion.EventCommentValue', to='gestion.EventCommentField')),
|
||||
('options', models.ManyToManyField(to='gestion.EventOptionChoice')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Inscription',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='eventcommentvalue',
|
||||
name='registration',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='gestion.EventRegistration'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='eventregistration',
|
||||
unique_together=set([('user', 'event')]),
|
||||
),
|
||||
migrations.RunPython(import_events, restore_events),
|
||||
]
|
|
@ -1,236 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11b1 on 2017-06-24 20:08
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('gestion', '0003_events'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='event',
|
||||
options={'verbose_name': 'événement', 'verbose_name_plural': 'événements'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='eventcommentfield',
|
||||
options={'verbose_name': 'champ', 'verbose_name_plural': 'champs'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='eventoption',
|
||||
options={'verbose_name': 'option des événements', 'verbose_name_plural': 'options des événements'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='eventoptionchoice',
|
||||
options={'verbose_name': 'choix', 'verbose_name_plural': 'choix'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='eventregistration',
|
||||
options={'verbose_name': 'inscription', 'verbose_name_plural': 'inscriptions'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='profile',
|
||||
options={'verbose_name': 'profil', 'verbose_name_plural': 'profils'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='eventcommentfield',
|
||||
name='ordering',
|
||||
field=models.IntegerField(default=0, help_text='plus petit en premier, ordre alphabétique sur le nom si ambiguïté', verbose_name='ordre des champs'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='cotisation_frequency',
|
||||
field=models.CharField(blank=True, choices=[('ANN', 'Annuel'), ('SEM', 'Semestriel'), ('COU', 'Au cours')], default='ANN', max_length=3, verbose_name='fréquence de la cotisation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, verbose_name='description'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='members',
|
||||
field=models.ManyToManyField(blank=True, related_name='in_clubs', through='gestion.ClubUser', to=settings.AUTH_USER_MODEL, verbose_name='membres du club'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, unique=True, verbose_name='nom'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='club',
|
||||
name='price',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=5, verbose_name='cotisation (€)'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clubuser',
|
||||
name='has_paid',
|
||||
field=models.BooleanField(verbose_name='a payé sa cotisation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='clubuser',
|
||||
name='is_respo',
|
||||
field=models.BooleanField(verbose_name='est responsable du club'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='associations',
|
||||
field=models.ManyToManyField(related_name='events', to='auth.Group', verbose_name='associations'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, verbose_name='description'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='end_date',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name="fin de l'événement"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, null=True, upload_to='public/imgs/events/', verbose_name='image'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='location',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='gestion.Location', verbose_name='lieux'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='old',
|
||||
field=models.BooleanField(default=False, verbose_name='archiver (événement fini)'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='registration_open',
|
||||
field=models.BooleanField(default=True, verbose_name='les inscriptions sont ouvertes'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='start_date',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name="début de l'événement"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='title',
|
||||
field=models.CharField(max_length=200, verbose_name='titre'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventcommentfield',
|
||||
name='default',
|
||||
field=models.TextField(blank=True, verbose_name='valeur par défaut'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventcommentfield',
|
||||
name='event',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commentfields', to='gestion.Event', verbose_name='événement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventcommentfield',
|
||||
name='fieldtype',
|
||||
field=models.CharField(choices=[('text', 'Texte long'), ('char', 'Texte court')], default='text', max_length=10, verbose_name='type de champ'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventcommentfield',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, verbose_name='nom du champ'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventcommentvalue',
|
||||
name='content',
|
||||
field=models.TextField(blank=True, verbose_name='contenu'),
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='eventcommentvalue',
|
||||
unique_together=set([('commentfield', 'registration')]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventoption',
|
||||
name='event',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='options', to='gestion.Event', verbose_name='événement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventoption',
|
||||
name='multi_choices',
|
||||
field=models.BooleanField(default=False, verbose_name='choix multiples'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventoption',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, verbose_name='option'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventoptionchoice',
|
||||
name='event_option',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='gestion.EventOption', verbose_name='événement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventregistration',
|
||||
name='event',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gestion.Event', verbose_name='événement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventregistration',
|
||||
name='filledcomments',
|
||||
field=models.ManyToManyField(through='gestion.EventCommentValue', to='gestion.EventCommentField', verbose_name='commentaires'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventregistration',
|
||||
name='options',
|
||||
field=models.ManyToManyField(to='gestion.EventOptionChoice', verbose_name='choix'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventregistration',
|
||||
name='paid',
|
||||
field=models.BooleanField(default=False, verbose_name='a payé'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='eventregistration',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='utilisateur'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='location',
|
||||
name='name',
|
||||
field=models.CharField(max_length=200, verbose_name='nom du lieux'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='comments',
|
||||
field=models.TextField(blank=True, verbose_name="commentaires visibles par l'utilisateur"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='departement',
|
||||
field=models.CharField(blank=True, max_length=50, verbose_name='département'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='login_clipper',
|
||||
field=models.CharField(blank=True, max_length=8, verbose_name='login clipper'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='occupation',
|
||||
field=models.CharField(choices=[('exterieur', 'Extérieur'), ('1A', '1A'), ('2A', '2A'), ('3A', '3A'), ('4A', '4A'), ('archicube', 'Archicube'), ('doctorant', 'Doctorant'), ('CST', 'CST')], default='1A', max_length=9, verbose_name='occupation'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='phone',
|
||||
field=models.CharField(blank=True, max_length=20, verbose_name='téléphone'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='profile',
|
||||
name='user',
|
||||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL, verbose_name='utilisateur'),
|
||||
),
|
||||
]
|
|
@ -1,60 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11b1 on 2017-06-25 17:21
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def create_apps(apps, schema_editor):
|
||||
Association = apps.get_model("gestion", "Association")
|
||||
Group = apps.get_model("auth", "Group")
|
||||
|
||||
cof_m, _ = Group.objects.get_or_create(name="cof_members")
|
||||
cof_b, _ = Group.objects.get_or_create(name="cof_buro")
|
||||
bds_m, _ = Group.objects.get_or_create(name="bds_members")
|
||||
bds_b, _ = Group.objects.get_or_create(name="bds_buro")
|
||||
|
||||
Association.objects.bulk_create([
|
||||
Association(name="COF", staff_group=cof_b, members_group=cof_m),
|
||||
Association(name="BDS", staff_group=bds_b, members_group=bds_m),
|
||||
])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0008_alter_user_username_max_length'),
|
||||
('gestion', '0004_verbose_names'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Association',
|
||||
fields=[
|
||||
('name', models.CharField(max_length=30, primary_key=True, serialize=False, verbose_name="nom de l'association")),
|
||||
('members_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='member_groups', to='auth.Group', verbose_name='groupe des membres')),
|
||||
('staff_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='staff_groups', to='auth.Group', verbose_name='groupe des membre du bureau')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'association',
|
||||
'verbose_name_plural': 'associations',
|
||||
},
|
||||
),
|
||||
migrations.RunPython(create_apps, migrations.RunPython.noop),
|
||||
migrations.RemoveField(
|
||||
model_name='club',
|
||||
name='associations',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='event',
|
||||
name='associations',
|
||||
field=models.ManyToManyField(related_name='events', to='gestion.Association', verbose_name='associations'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='club',
|
||||
name='association',
|
||||
field=models.ForeignKey(default="COF", on_delete=django.db.models.deletion.PROTECT, related_name='clubs', to='gestion.Association', verbose_name='association'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -235,6 +235,7 @@ class EventCommentField(models.Model):
|
|||
default = models.TextField(_("valeur par défaut"), blank=True)
|
||||
ordering = models.IntegerField(
|
||||
_("ordre des champs"),
|
||||
default=0,
|
||||
help_text=_(
|
||||
"plus petit en premier, ordre alphabétique sur le nom si "
|
||||
"ambiguïté"
|
||||
|
|
Loading…
Reference in a new issue