From ebd5b88315a6b086ac39efd141a17b79dacdc667 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sun, 30 Sep 2018 07:27:15 +0200 Subject: [PATCH] Add AlternativeEmail --- .../migrations/0003_auto_20180930_0726.py | 34 +++++++++++++++++++ profiles/models.py | 15 +++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 profiles/migrations/0003_auto_20180930_0726.py diff --git a/profiles/migrations/0003_auto_20180930_0726.py b/profiles/migrations/0003_auto_20180930_0726.py new file mode 100644 index 000000000..3cb4f29f4 --- /dev/null +++ b/profiles/migrations/0003_auto_20180930_0726.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-09-30 05:26 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('profiles', '0002_auto_20180916_1643'), + ] + + operations = [ + migrations.CreateModel( + name='AlternativeEmail', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('email', models.EmailField(max_length=254)), + ('still_valid', models.BooleanField(default=True)), + ], + ), + migrations.AlterField( + model_name='profile', + name='email', + field=models.EmailField(max_length=254), + ), + migrations.AddField( + model_name='alternativeemail', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='profiles.Profile'), + ), + ] diff --git a/profiles/models.py b/profiles/models.py index ee8aea204..3d501d75f 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -36,7 +36,7 @@ class Profile(models.Model): title = models.CharField(max_length=4, choices=TITLE_CHOICES) first_name = models.CharField(max_length=64) last_name = models.CharField(max_length=64) - email = models.EmailField(unique=True) + email = models.EmailField() discipline = models.CharField(max_length=20, choices=SCIPOST_DISCIPLINES, default=DISCIPLINE_PHYSICS, verbose_name='Main discipline') expertises = ChoiceArrayField( @@ -54,3 +54,16 @@ class Profile(models.Model): def __str__(self): return '%s, %s %s' % (self.last_name, self.get_title_display(), self.first_name) + + +class AlternativeEmail(models.Model): + """ + It is often the case that somebody has multiple email addresses. + The 'email' field of a given Profile, Contributor or other person-based object + is then interpreted as representing the current address. + An AlternativeEmail is bound to a Profile and holds info on eventual + secondary email addresses. + """ + profile = models.ForeignKey(Profile, on_delete=models.CASCADE) + email = models.EmailField() + still_valid = models.BooleanField(default=True) -- GitLab