Use CIEmailField for teacher email in order to prevent duplicate email

This commit is contained in:
Gabriel Augendre 2019-06-27 19:12:04 +02:00
parent 8961964ef1
commit bdf4309781
2 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,25 @@
# Generated by Django 2.2.2 on 2019-06-27 17:05
import django.contrib.postgres.fields.citext
from django.contrib.postgres.operations import CITextExtension
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('manuels', '0036_auto_20190615_1114'),
]
operations = [
migrations.AlterModelOptions(
name='commonsupply',
options={'ordering': ('order', 'name'), 'verbose_name': 'fourniture commune', 'verbose_name_plural': 'fournitures communes'},
),
CITextExtension(),
migrations.AlterField(
model_name='teacher',
name='email',
field=django.contrib.postgres.fields.citext.CIEmailField(help_text='Utilisée pour vous transmettre votre lien personnel', max_length=254, unique=True, verbose_name='adresse email'),
),
]

View file

@ -4,6 +4,7 @@ import re
import uuid as uuid
from django.conf import settings
from django.contrib.postgres.fields import CIEmailField
from django.core.exceptions import ValidationError
from django.core.mail import EmailMultiAlternatives
from django.db import models
@ -43,7 +44,7 @@ class Teacher(BaseModel):
max_length=10,
validators=[phone_validator]
)
email = models.EmailField(
email = CIEmailField(
'adresse email',
help_text='Utilisée pour vous transmettre votre lien personnel',
unique=True