summaryrefslogtreecommitdiff
path: root/pgcommitfest/userprofile/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2015-01-22 14:04:09 +0000
committerMagnus Hagander2015-01-22 14:04:09 +0000
commit0c58317302c0eeea57dcbafa28b5150b82eba3de (patch)
tree2f02f27f4780e89b1bd9918ceb7f6f1477328ad8 /pgcommitfest/userprofile/models.py
parentc80b7e1d58f3bac19a6df99ddf3d4bfc50e6a2ee (diff)
Implement support for secondary email addresses
Each user can add a secondary email (well, more than one) and then pick one of those when sending email. Addresses are validated by sending a token to the newly added address, with a link to click to confirm it. Only a fully confirmed address can actually be used.
Diffstat (limited to 'pgcommitfest/userprofile/models.py')
-rw-r--r--pgcommitfest/userprofile/models.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pgcommitfest/userprofile/models.py b/pgcommitfest/userprofile/models.py
new file mode 100644
index 0000000..c5a982c
--- /dev/null
+++ b/pgcommitfest/userprofile/models.py
@@ -0,0 +1,25 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+class UserExtraEmail(models.Model):
+ user = models.ForeignKey(User, null=False, blank=False, db_index=True)
+ email = models.EmailField(max_length=100, null=False, blank=False, unique=True)
+ confirmed = models.BooleanField(null=False, blank=False, default=False)
+ token = models.CharField(max_length=100, null=False, blank=True)
+ tokensent = models.DateTimeField(null=False, blank=False)
+
+ def __unicode__(self):
+ return self.email
+
+ class Meta:
+ ordering = ('user', 'email')
+ unique_together = (('user', 'email'),)
+
+
+class UserProfile(models.Model):
+ user = models.ForeignKey(User, null=False, blank=False)
+ selectedemail = models.ForeignKey(UserExtraEmail, null=True, blank=True,
+ verbose_name='Sender email')
+
+ def __unicode__(self):
+ return unicode(self.user)