forked from DGNum/gestioCOF
Replace unique_together by UniqueConstraint
This commit is contained in:
parent
1b143b322f
commit
84c87c1b4b
7 changed files with 172 additions and 9 deletions
23
bda/migrations/0020_auto_20220630_1035.py
Normal file
23
bda/migrations/0020_auto_20220630_1035.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-06-30 08:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bda", "0019_auto_20220628_1621"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="choixspectacle",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="choixspectacle",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("participant", "spectacle"), name="unique_participation"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -253,7 +253,11 @@ class ChoixSpectacle(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ("priority",)
|
ordering = ("priority",)
|
||||||
unique_together = (("participant", "spectacle"),)
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["participant", "spectacle"], name="unique_participation"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = "voeu"
|
verbose_name = "voeu"
|
||||||
verbose_name_plural = "voeux"
|
verbose_name_plural = "voeux"
|
||||||
|
|
||||||
|
|
63
events/migrations/0006_auto_20220630_1035.py
Normal file
63
events/migrations/0006_auto_20220630_1035.py
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-06-30 08:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("events", "0005_auto_20220628_1621"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="extrafield",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="extrafieldcontent",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="option",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="optionchoice",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="registration",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="extrafield",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("event", "name"), name="unique_extra_field"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="extrafieldcontent",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("field", "registration"), name="unique_extra_field_content"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="option",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("event", "name"), name="unique_event_option"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="optionchoice",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("option", "choice"), name="unique_option_choice"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="registration",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("event", "user"), name="unique_registration"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -72,9 +72,13 @@ class Option(models.Model):
|
||||||
multi_choices = models.BooleanField(_("choix multiples"), default=False)
|
multi_choices = models.BooleanField(_("choix multiples"), default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["event", "name"], name="unique_event_option"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = _("option d'événement")
|
verbose_name = _("option d'événement")
|
||||||
verbose_name_plural = _("options d'événement")
|
verbose_name_plural = _("options d'événement")
|
||||||
unique_together = [["event", "name"]]
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -87,9 +91,13 @@ class OptionChoice(models.Model):
|
||||||
choice = models.CharField(_("choix"), max_length=200)
|
choice = models.CharField(_("choix"), max_length=200)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["option", "choice"], name="unique_option_choice"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = _("choix d'option d'événement")
|
verbose_name = _("choix d'option d'événement")
|
||||||
verbose_name_plural = _("choix d'option d'événement")
|
verbose_name_plural = _("choix d'option d'événement")
|
||||||
unique_together = [["option", "choice"]]
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.choice
|
return self.choice
|
||||||
|
@ -118,7 +126,9 @@ class ExtraField(models.Model):
|
||||||
field_type = models.CharField(_("type de champ"), max_length=9, choices=FIELD_TYPE)
|
field_type = models.CharField(_("type de champ"), max_length=9, choices=FIELD_TYPE)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = [["event", "name"]]
|
constraints = [
|
||||||
|
models.UniqueConstraint(fields=["event", "name"], name="unique_extra_field")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class ExtraFieldContent(models.Model):
|
class ExtraFieldContent(models.Model):
|
||||||
|
@ -137,9 +147,13 @@ class ExtraFieldContent(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["field", "registration"], name="unique_extra_field_content"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = _("contenu d'un champ événement supplémentaire")
|
verbose_name = _("contenu d'un champ événement supplémentaire")
|
||||||
verbose_name_plural = _("contenus d'un champ événement supplémentaire")
|
verbose_name_plural = _("contenus d'un champ événement supplémentaire")
|
||||||
unique_together = [["field", "registration"]]
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
max_length = 50
|
max_length = 50
|
||||||
|
@ -163,9 +177,13 @@ class Registration(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["event", "user"], name="unique_registration"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = _("inscription à un événement")
|
verbose_name = _("inscription à un événement")
|
||||||
verbose_name_plural = _("inscriptions à un événement")
|
verbose_name_plural = _("inscriptions à un événement")
|
||||||
unique_together = [["event", "user"]]
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "inscription de {} à {}".format(self.user, self.event)
|
return "inscription de {} à {}".format(self.user, self.event)
|
||||||
|
|
43
gestioncof/migrations/0020_auto_20220630_1036.py
Normal file
43
gestioncof/migrations/0020_auto_20220630_1036.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-06-30 08:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("gestioncof", "0019_auto_20220628_1621"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="eventregistration",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="petitcoursability",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="surveyanswer",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="eventregistration",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("user", "event"), name="unique_event_registration"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="petitcoursability",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("user", "niveau", "matiere"), name="unique_competence_level"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="surveyanswer",
|
||||||
|
constraint=models.UniqueConstraint(
|
||||||
|
fields=("user", "survey"), name="unique_survey_answer"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -194,8 +194,12 @@ class EventRegistration(models.Model):
|
||||||
paid = models.BooleanField("A payé", default=False)
|
paid = models.BooleanField("A payé", default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["user", "event"], name="unique_event_registration"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = "Inscription"
|
verbose_name = "Inscription"
|
||||||
unique_together = ("user", "event")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Inscription de {} à {}".format(self.user, self.event.title)
|
return "Inscription de {} à {}".format(self.user, self.event.title)
|
||||||
|
@ -247,8 +251,12 @@ class SurveyAnswer(models.Model):
|
||||||
answers = models.ManyToManyField(SurveyQuestionAnswer, related_name="selected_by")
|
answers = models.ManyToManyField(SurveyQuestionAnswer, related_name="selected_by")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["user", "survey"], name="unique_survey_answer"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = "Réponses"
|
verbose_name = "Réponses"
|
||||||
unique_together = ("user", "survey")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Réponse de %s sondage %s" % (
|
return "Réponse de %s sondage %s" % (
|
||||||
|
|
|
@ -44,9 +44,13 @@ class PetitCoursAbility(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = "gestioncof"
|
app_label = "gestioncof"
|
||||||
|
constraints = [
|
||||||
|
models.UniqueConstraint(
|
||||||
|
fields=["user", "niveau", "matiere"], name="unique_competence_level"
|
||||||
|
)
|
||||||
|
]
|
||||||
verbose_name = "Compétence petits cours"
|
verbose_name = "Compétence petits cours"
|
||||||
verbose_name_plural = "Compétences des petits cours"
|
verbose_name_plural = "Compétences des petits cours"
|
||||||
unique_together = ("user", "niveau", "matiere")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{:s} - {!s} - {:s}".format(
|
return "{:s} - {!s} - {:s}".format(
|
||||||
|
|
Loading…
Reference in a new issue