Skip to content

Commit

Permalink
accounts: admin: override to add full access to devices field
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Jun 13, 2022
1 parent 7e21bd1 commit b3f526e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _
from core.models import Device

User = get_user_model()
Expand All @@ -16,9 +17,29 @@ class CustomUserAdmin(UserAdmin):
"get_devices",
"is_staff",
"is_superuser",
"full_access_to_devices",
]
ordering = ["-is_active", "-last_login"]

fieldsets = (
(None, {"fields": ("username", "password")}),
(_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
(
_("Permissions"),
{
"fields": (
"is_active",
"is_staff",
"is_superuser",
"full_access_to_devices",
"groups",
"user_permissions",
),
},
),
(_("Important dates"), {"fields": ("last_login", "date_joined")}),
)

def get_full_name(self, obj):
return "{} {}".format(obj.first_name, obj.last_name)

Expand Down

0 comments on commit b3f526e

Please sign in to comment.