From fece0d58cc12d1cbfdcc16066265e5ff8aacbcc4 Mon Sep 17 00:00:00 2001 From: Siobhan Tully Date: Fri, 6 Sep 2013 12:57:05 -0400 Subject: [PATCH] Consolidated email and username fields to preserve availability on both indexes --- planetstack/core/admin.py | 6 +++--- planetstack/core/models/user.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py index b80855e..bae7be1 100644 --- a/planetstack/core/admin.py +++ b/planetstack/core/admin.py @@ -630,18 +630,18 @@ class UserAdmin(UserAdmin): # The fields to be used in displaying the User model. # These override the definitions on the base UserAdmin # that reference specific fields on auth.User. - list_display = ('email', 'username','firstname', 'lastname', 'is_admin', 'last_login') + list_display = ('email', 'firstname', 'lastname', 'is_admin', 'last_login') list_filter = () inlines = [SlicePrivilegeInline,SitePrivilegeInline,DeploymentPrivilegeInline] fieldsets = ( - ('Login Details', {'fields': ('email', 'username','site','password', 'is_admin', 'public_key'), 'classes':['suit-tab suit-tab-general']}), + ('Login Details', {'fields': ('email', 'site','password', 'is_admin', 'public_key'), 'classes':['suit-tab suit-tab-general']}), ('Contact Information', {'fields': ('firstname','lastname','phone', 'timezone'), 'classes':['suit-tab suit-tab-contact']}), #('Important dates', {'fields': ('last_login',)}), ) add_fieldsets = ( (None, { 'classes': ('wide',), - 'fields': ('email', 'username','firstname', 'lastname', 'phone', 'public_key','password1', 'password2')} + 'fields': ('email', 'firstname', 'lastname', 'phone', 'public_key','password1', 'password2')} ), ) search_fields = ('email',) diff --git a/planetstack/core/models/user.py b/planetstack/core/models/user.py index 2b63dda..32f2078 100644 --- a/planetstack/core/models/user.py +++ b/planetstack/core/models/user.py @@ -54,7 +54,9 @@ class User(AbstractBaseUser): unique=True, db_index=True, ) - username = models.CharField(max_length=200, default="Something" ) + + username = models.CharField(max_length=255, default="Something" ) + kuser_id = models.CharField(null=True, blank=True, help_text="keystone user id", max_length=200) firstname = models.CharField(help_text="person's given name", max_length=200) @@ -124,4 +126,5 @@ class User(AbstractBaseUser): def save(self, *args, **kwds): if not self.id: self.set_password(self.password) + self.username = self.email super(User, self).save(*args, **kwds) -- 2.43.0