Expand UserProfile admin, auto-set profile realname if possible
This commit is contained in:
parent
3a9d1b6863
commit
0b239e553a
2 changed files with 8 additions and 1 deletions
|
@ -22,7 +22,9 @@ class CityAdmin(admin.ModelAdmin):
|
|||
search_fields = ('name', 'spr__name')
|
||||
admin.site.register(City, CityAdmin)
|
||||
|
||||
admin.site.register(UserProfile)
|
||||
class ProfileAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'realname', 'avatar', 'web_url')
|
||||
admin.site.register(UserProfile, ProfileAdmin)
|
||||
|
||||
class OrgAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'site')
|
||||
|
|
|
@ -100,6 +100,11 @@ def _getUserProfile(self):
|
|||
|
||||
if created:
|
||||
profile.tz = get_user_timezone(self.username)
|
||||
if self.first_name:
|
||||
if self.last_name:
|
||||
profile.realname = '%s %s' % (self.first_name, self.last_name)
|
||||
else:
|
||||
profile.realname = self.first_name
|
||||
profile.save()
|
||||
|
||||
return profile
|
||||
|
|
Loading…
Reference in a new issue