mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
newforms-admin: Converted django.contrib.auth model admin options to use new syntax
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@4947 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1df79c5115
commit
1cf0a2d792
@ -63,10 +63,6 @@ class Group(models.Model):
|
||||
verbose_name_plural = _('groups')
|
||||
ordering = ('name',)
|
||||
|
||||
class Admin:
|
||||
search_fields = ('name',)
|
||||
filter_horizontal = ('permissions',)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@ -111,19 +107,6 @@ class User(models.Model):
|
||||
verbose_name_plural = _('users')
|
||||
ordering = ('username',)
|
||||
|
||||
class Admin:
|
||||
fields = (
|
||||
(None, {'fields': ('username', 'password')}),
|
||||
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
|
||||
(_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),
|
||||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
||||
(_('Groups'), {'fields': ('groups',)}),
|
||||
)
|
||||
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
|
||||
list_filter = ('is_staff', 'is_superuser')
|
||||
search_fields = ('username', 'first_name', 'last_name', 'email')
|
||||
filter_horizontal = ('user_permissions',)
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
|
||||
@ -320,3 +303,29 @@ class AnonymousUser(object):
|
||||
|
||||
def is_authenticated(self):
|
||||
return False
|
||||
|
||||
# Register the admin options for these models.
|
||||
# TODO: Maybe this should live in a separate module admin.py, but how would we
|
||||
# ensure that module was loaded?
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
search_fields = ('name',)
|
||||
filter_horizontal = ('permissions',)
|
||||
|
||||
class UserAdmin(admin.ModelAdmin):
|
||||
fields = (
|
||||
(None, {'fields': ('username', 'password')}),
|
||||
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
|
||||
(_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),
|
||||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
||||
(_('Groups'), {'fields': ('groups',)}),
|
||||
)
|
||||
list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
|
||||
list_filter = ('is_staff', 'is_superuser')
|
||||
search_fields = ('username', 'first_name', 'last_name', 'email')
|
||||
filter_horizontal = ('user_permissions',)
|
||||
|
||||
admin.site.register(Group, GroupAdmin)
|
||||
admin.site.register(User, UserAdmin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user