fmartingr
/
shelfzilla
Archived
1
0
Fork 0
This repository has been archived on 2021-06-29. You can view files and clone it, but cannot push or open issues or pull requests.
shelfzilla/shelfzilla/apps/account/admin.py

58 lines
1.8 KiB
Python
Raw Normal View History

2014-11-04 22:36:19 +00:00
# -*- coding: utf-8 -*-
"""
License boilerplate should be used here.
"""
# python 3 imports
from __future__ import absolute_import, unicode_literals
# python imports
import logging
# django imports
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.contrib.auth.models import Permission
from django.utils.translation import ugettext_lazy as _
# app imports
from . import models
logger = logging.getLogger(__name__)
class UserAdmin(DjangoUserAdmin):
# The forms to add and change user instances
2014-11-10 09:11:51 +00:00
# form = UserChangeForm
# add_form = UserCreationForm
2014-11-04 22:36:19 +00:00
# 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', 'first_name', 'last_name', 'is_active')
list_filter = ('is_staff',)
fieldsets = (
(None, {'fields': ('username', 'email', 'password')}),
(_('Personal info'), {'fields': (
'first_name', 'last_name', 'birthdate', 'gender', )}),
2014-11-10 09:11:51 +00:00
(_('Permissions'), {'fields': ('is_staff', 'user_permissions')}),
(_('Information'), {'fields': ('date_joined', 'last_login', )})
2014-11-04 22:36:19 +00:00
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = (
(None, {
'classes': ('wide',),
2014-11-10 09:11:51 +00:00
'fields': ('username', 'email', 'password1', 'password2')
2014-11-04 22:36:19 +00:00
}),
)
search_fields = ('email',)
ordering = ('email',)
2014-11-10 09:11:51 +00:00
filter_horizontal = ('user_permissions', )
readonly_fields = ('date_joined', 'last_login', )
2014-11-04 22:36:19 +00:00
# Now register the new UserAdmin...
admin.site.register(models.User, UserAdmin)
admin.site.register(Permission)