summaryrefslogtreecommitdiff
path: root/postgresqleu/util/fields.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-07-10 20:40:06 +0000
committerMagnus Hagander2019-07-10 20:40:06 +0000
commitdf9fe517efea219490bf26061dbef9384d3c5736 (patch)
treef95118896f6eca92ae22987790e8abf1aa6afca1 /postgresqleu/util/fields.py
parent44eb63bd041ceed2af9ec499ee80da813a620942 (diff)
Ensure email addresses are lowercase throughout
At least all email addresses being input by end users should be confverted to lowercase to avoid duplicates. Update existing users, registrations and election candidates to be lowercase, and add constraints to them For things like conference contract addresses that are only set by superusers, we skip the constraints part and let the user take some more responsibility.
Diffstat (limited to 'postgresqleu/util/fields.py')
-rw-r--r--postgresqleu/util/fields.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/postgresqleu/util/fields.py b/postgresqleu/util/fields.py
new file mode 100644
index 00000000..b1ed1190
--- /dev/null
+++ b/postgresqleu/util/fields.py
@@ -0,0 +1,9 @@
+from django.db import models
+
+
+class LowercaseEmailField(models.EmailField):
+ def get_prep_value(self, value):
+ value = super(models.EmailField, self).get_prep_value(value)
+ if value is not None:
+ value = value.lower()
+ return value