-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
38 lines (35 loc) · 1.43 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.contrib import admin
from django.contrib.auth import admin as auth_admin
from .models import User, Organization
from .forms import UserChangeForm, UserCreationForm
# Register your models here.
admin.site.register(Organization)
@admin.register(User)
class AdminUser(auth_admin.UserAdmin):
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {'fields': ('name', 'phone', 'birthdate', 'organization')}),
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser',
'groups', 'user_permissions')}),
('Important dates', {'fields': ('last_login', 'date_joined')}),
)
limited_fieldsets = (
(None, {'fields': ('email',)}),
('Personal info', {
'fields': ('name', 'phone', 'birthdate')}),
('Important dates', {'fields': ('last_login', 'date_joined')}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2')}
),
)
form = UserChangeForm
add_form = UserCreationForm
change_password_form = auth_admin.AdminPasswordChangeForm
list_display = ('id', 'email', 'name', 'organization', 'is_staff')
list_filter = ('phone', 'organization', 'is_staff', 'is_superuser', 'is_active', 'groups')
search_fields = ('name', 'email')
ordering = ('email',)
readonly_fields = ('last_login', 'date_joined',)