2024-01-09 15:30:36 +01:00
|
|
|
"""Admin classes and registrations for core app."""
|
2024-07-30 16:48:26 +02:00
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
from django.contrib import admin
|
|
|
|
|
from django.contrib.auth import admin as auth_admin
|
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
|
|
from . import models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.User)
|
|
|
|
|
class UserAdmin(auth_admin.UserAdmin):
|
|
|
|
|
"""Admin class for the User model"""
|
|
|
|
|
|
|
|
|
|
fieldsets = (
|
|
|
|
|
(
|
|
|
|
|
None,
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"id",
|
|
|
|
|
"admin_email",
|
|
|
|
|
"password",
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-11-13 11:43:14 +01:00
|
|
|
(
|
|
|
|
|
_("Personal info"),
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"sub",
|
|
|
|
|
"email",
|
|
|
|
|
"full_name",
|
|
|
|
|
"short_name",
|
|
|
|
|
"language",
|
|
|
|
|
"timezone",
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-01-09 15:30:36 +01:00
|
|
|
(
|
|
|
|
|
_("Permissions"),
|
|
|
|
|
{
|
|
|
|
|
"fields": (
|
|
|
|
|
"is_active",
|
|
|
|
|
"is_device",
|
|
|
|
|
"is_staff",
|
|
|
|
|
"is_superuser",
|
|
|
|
|
"groups",
|
|
|
|
|
"user_permissions",
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
(_("Important dates"), {"fields": ("created_at", "updated_at")}),
|
|
|
|
|
)
|
|
|
|
|
add_fieldsets = (
|
|
|
|
|
(
|
|
|
|
|
None,
|
|
|
|
|
{
|
|
|
|
|
"classes": ("wide",),
|
|
|
|
|
"fields": ("email", "password1", "password2"),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
list_display = (
|
|
|
|
|
"id",
|
|
|
|
|
"sub",
|
|
|
|
|
"admin_email",
|
|
|
|
|
"email",
|
2024-11-13 11:43:14 +01:00
|
|
|
"full_name",
|
|
|
|
|
"short_name",
|
2024-01-09 15:30:36 +01:00
|
|
|
"is_active",
|
|
|
|
|
"is_staff",
|
|
|
|
|
"is_superuser",
|
|
|
|
|
"is_device",
|
|
|
|
|
"created_at",
|
|
|
|
|
"updated_at",
|
|
|
|
|
)
|
|
|
|
|
list_filter = ("is_staff", "is_superuser", "is_device", "is_active")
|
2024-11-13 11:43:14 +01:00
|
|
|
ordering = (
|
|
|
|
|
"is_active",
|
|
|
|
|
"-is_superuser",
|
|
|
|
|
"-is_staff",
|
|
|
|
|
"-is_device",
|
|
|
|
|
"-updated_at",
|
|
|
|
|
"full_name",
|
|
|
|
|
)
|
|
|
|
|
readonly_fields = (
|
|
|
|
|
"id",
|
|
|
|
|
"sub",
|
|
|
|
|
"email",
|
|
|
|
|
"full_name",
|
|
|
|
|
"short_name",
|
|
|
|
|
"created_at",
|
|
|
|
|
"updated_at",
|
|
|
|
|
)
|
|
|
|
|
search_fields = ("id", "sub", "admin_email", "email", "full_name")
|
2024-06-25 00:21:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResourceAccessInline(admin.TabularInline):
|
|
|
|
|
"""Admin class for the room user access model"""
|
|
|
|
|
|
|
|
|
|
model = models.ResourceAccess
|
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Room)
|
|
|
|
|
class RoomAdmin(admin.ModelAdmin):
|
|
|
|
|
"""Room admin interface declaration."""
|
|
|
|
|
|
|
|
|
|
inlines = (ResourceAccessInline,)
|
2024-11-06 18:47:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class RecordingAccessInline(admin.TabularInline):
|
|
|
|
|
"""Inline admin class for recording accesses."""
|
|
|
|
|
|
|
|
|
|
model = models.RecordingAccess
|
|
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(models.Recording)
|
|
|
|
|
class RecordingAdmin(admin.ModelAdmin):
|
|
|
|
|
"""Recording admin interface declaration."""
|
|
|
|
|
|
|
|
|
|
inlines = (RecordingAccessInline,)
|
|
|
|
|
list_display = ("id", "status", "room", "created_at", "worker_id")
|