Skip to content

Commit

Permalink
[add] Added TOTP Devices segment for admin page.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Mar 28, 2024
1 parent 3caa674 commit 0a66eff
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions custom_auth/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from custom_auth.models import User, Group, UserActivateToken
from custom_auth.models import User, Group, UserActivateToken, TOTPDevice


class TermInlineUserAdmin(admin.TabularInline):
Expand All @@ -20,7 +20,7 @@ class User(admin.ModelAdmin):
('Flags', {'fields': ('is_active', 'is_staff', 'allow_group_add')}),
('Important dates', {'fields': ('last_login', 'created_at', 'updated_at')}),
)
list_display = ('username', 'username_jp',)
list_display = ('username', 'username_jp', 'is_active', 'is_staff',)
list_filter = ('is_staff', 'is_active',)
search_fields = ('username', 'username_jp', 'email')
readonly_fields = ('last_login', 'created_at', 'updated_at',)
Expand All @@ -41,7 +41,7 @@ class Group(admin.ModelAdmin):
('Personal info', {'fields': ('postcode', 'address', 'address_jp', 'phone', 'country', 'contract_type',)}),
)
list_display = ('name', 'name_jp', 'membership_type', 'membership_expired_at',)
list_filter = ('membership_type',)
list_filter = ('membership_type', 'is_pass', 'allow_service_add',)
search_fields = ('name', 'name_jp',)
readonly_fields = ('created_at', 'updated_at',)

Expand All @@ -55,4 +55,16 @@ class UserActivateToken(admin.ModelAdmin):
('Important dates', {'fields': ('created_at',)}),
)
list_display = ('user', 'token', 'expired_at', 'is_used')
list_filter = ('is_used',)
search_fields = ('user', 'token', 'expired_at', 'is_used')


@admin.register(TOTPDevice)
class TOTPDevice(admin.ModelAdmin):
fieldsets = (
(None, {"fields": ('title', 'is_active', 'user', 'secret')}),
('Important dates', {'fields': ('created_at',)}),
)
list_display = ('id', 'is_active', 'title', 'user',)
list_filter = ('is_active',)
search_fields = ('id', 'is_active', 'title',)

0 comments on commit 0a66eff

Please sign in to comment.