admin.py 935 Bytes
Newer Older
luxcem's avatar
luxcem committed
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
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User, Permission
from django.utils.translation import ugettext_lazy as _

from userprofile.models import Profile


@admin.register(Permission)
class PermissionAdmin(admin.ModelAdmin):
    list_display = ("name", "codename", "content_type")
    list_filter = ("content_type",)


class UserProfileInline(admin.StackedInline):
    model = Profile
    list_display = ("user", "full_name")

    extra = 1
    max_num = 1


class UserProfileAdmin(UserAdmin):
    inlines = [UserProfileInline]
    fieldsets = (
        (None, {"fields": ("username", "password")}),
        (_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
        (_("Permissions"), {
            "fields": ("is_active", "is_staff", "is_superuser")}),
    )


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)