2026-02-26 01:32:04 +00:00
|
|
|
from django.contrib import admin
|
2026-03-08 13:10:49 +00:00
|
|
|
from django.contrib.admin import ModelAdmin
|
2026-02-26 01:32:04 +00:00
|
|
|
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
|
|
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
|
|
2026-03-08 13:10:49 +00:00
|
|
|
from apps.accounts.models import Invite, Organization, Role, User
|
2026-02-26 01:32:04 +00:00
|
|
|
|
|
|
|
|
admin.site.unregister(Group)
|
|
|
|
|
|
|
|
|
|
@admin.register(User)
|
|
|
|
|
class UserAdmin(DjangoUserAdmin):
|
|
|
|
|
fieldsets = (
|
|
|
|
|
(None, {'fields': ('email_address', 'password')}),
|
|
|
|
|
('Personal info', {'fields': ('first_name', 'last_name')}),
|
|
|
|
|
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser', 'is_manager')}),
|
|
|
|
|
('Dates', {'fields': ('last_login',)}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_fieldsets = (
|
|
|
|
|
(None, {
|
|
|
|
|
'classes': ('wide',),
|
|
|
|
|
'fields': ('email_address', 'first_name', 'last_name', 'password1', 'password2'),
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
list_display = ('email_address', 'first_name', 'last_name', 'is_staff', 'is_manager')
|
|
|
|
|
search_fields = ('email_address', 'first_name', 'last_name')
|
|
|
|
|
ordering = ('email_address',)
|
|
|
|
|
|
|
|
|
|
@admin.register(Organization)
|
|
|
|
|
class OrganizationAdmin(ModelAdmin):
|
|
|
|
|
list_display = ('name', 'owner', 'uuid', 'created_at')
|
|
|
|
|
search_fields = ('name', 'owner__email_address')
|
|
|
|
|
list_filter = ('created_at',)
|
|
|
|
|
raw_id_fields = ('owner',)
|
|
|
|
|
readonly_fields = ('uuid', 'created_at', 'updated_at')
|
|
|
|
|
|
|
|
|
|
@admin.register(Invite)
|
|
|
|
|
class InviteAdmin(ModelAdmin):
|
2026-02-27 12:53:19 +00:00
|
|
|
list_display = ('uuid', 'organization', 'created_by', 'is_active', 'uses', 'max_uses', 'expires_at')
|
|
|
|
|
search_fields = ('uuid', 'organization__name', 'created_by__email_address')
|
2026-02-26 01:32:04 +00:00
|
|
|
list_filter = ('is_active', 'expires_at')
|
|
|
|
|
raw_id_fields = ('organization', 'created_by')
|
2026-02-27 12:53:19 +00:00
|
|
|
readonly_fields = ('uuid', 'created_at')
|
2026-02-26 01:32:04 +00:00
|
|
|
|
|
|
|
|
@admin.register(Role)
|
|
|
|
|
class RoleAdmin(ModelAdmin):
|
|
|
|
|
list_display = ('name', 'organization', 'uuid')
|
|
|
|
|
search_fields = ('name', 'organization__name')
|
|
|
|
|
list_filter = ('organization',)
|
|
|
|
|
raw_id_fields = ('organization',)
|
|
|
|
|
readonly_fields = ('uuid', 'created_at', 'updated_at')
|