Skip to content

Commit f645214

Browse files
committed
Add email field to Account
As suggested in code review, many libraries expect the Django user account to have an email field. The AbstractUser implementation even provides a method to get the name of the field that contains the user's email address. NAV currently has no need for emails attached directly to user objects, so this field is just being added for the sake of compatibility. It may slip into usage at a later stage.
1 parent c3d0692 commit f645214

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

python/nav/models/profiles.py

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Account(AbstractBaseUser):
8888
"""NAV's basic account model"""
8989

9090
USERNAME_FIELD = 'login'
91+
EMAIL_FIELD = 'email'
9192
DEFAULT_ACCOUNT = 0
9293
ADMIN_ACCOUNT = 1
9394

@@ -105,6 +106,7 @@ class Account(AbstractBaseUser):
105106

106107
login = VarcharField(unique=True)
107108
name = VarcharField()
109+
email = models.EmailField(null=True, blank=True) # Not currently used by NAV
108110
password = VarcharField()
109111
ext_sync = VarcharField(blank=True)
110112
preferences = HStoreField(default=dict)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add email column to account table just to be more compatible with Django user models
2+
ALTER TABLE account ADD COLUMN email VARCHAR(254) DEFAULT NULL;

0 commit comments

Comments
 (0)