Merge branch 'Kerl/unique_login_clipper' into 'master'

Force l'unicité des clippers

See merge request klub-dev-ens/gestioCOF!346
This commit is contained in:
Aurélien Delobelle 2019-01-15 20:18:33 +01:00
commit be155f2f2d
3 changed files with 49 additions and 1 deletions

View file

@ -1,3 +1,4 @@
- Force l'unicité des logins clipper
- Nouveau site du COF en wagtail
- Meilleurs affichage des longues listes de spectacles à cocher dans BdA-Revente
- Bugfix : les pages de la revente ne sont plus accessibles qu'aux membres du

View file

@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-01-14 21:36
from __future__ import unicode_literals
from django.db import migrations, models
def empty_clippers_to_null(apps, schema_editor):
CofProfile = apps.get_model("gestioncof", "CofProfile")
CofProfile.objects.filter(login_clipper="").update(login_clipper=None)
def null_clippers_to_empty(apps, schema_editor):
CofProfile = apps.get_model("gestioncof", "CofProfile")
CofProfile.objects.filter(login_clipper__isnull=True).update(login_clipper="")
class Migration(migrations.Migration):
dependencies = [("gestioncof", "0015_psql_choices_niveaux")]
operations = [
# First, only set null to True (unique is still False)
migrations.AlterField(
model_name="cofprofile",
name="login_clipper",
field=models.CharField(
blank=True, max_length=32, null=True, verbose_name="Login clipper"
),
),
# Then, set all empty login_clippers to null
migrations.RunPython(empty_clippers_to_null),
# Finally set unique to True
migrations.AlterField(
model_name="cofprofile",
name="login_clipper",
field=models.CharField(
blank=True,
max_length=32,
null=True,
unique=True,
verbose_name="Login clipper",
),
),
]

View file

@ -46,7 +46,9 @@ class CofProfile(models.Model):
)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
login_clipper = models.CharField("Login clipper", max_length=32, blank=True)
login_clipper = models.CharField(
"Login clipper", max_length=32, blank=True, unique=True, null=True
)
is_cof = models.BooleanField("Membre du COF", default=False)
phone = models.CharField("Téléphone", max_length=20, blank=True)
occupation = models.CharField(