mpeltriaux
b0f3505972
* removes admin backend views which are not important for production * adds filtering functionalities on index views * simplifies detail views on intervention, compensation, ecoaccount and ema * adds autocomplete fields on detail views * adds handy horizontal filter fields on detail views
72 lines
1.4 KiB
Python
72 lines
1.4 KiB
Python
from django.contrib import admin
|
|
|
|
from user.models import UserNotification, UserActionLogEntry, User
|
|
|
|
|
|
class UserNotificationAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"name",
|
|
"is_active",
|
|
]
|
|
|
|
|
|
class UserAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"username",
|
|
"first_name",
|
|
"last_name",
|
|
"email",
|
|
]
|
|
fields = [
|
|
"username",
|
|
"first_name",
|
|
"last_name",
|
|
"email",
|
|
"is_active",
|
|
"is_staff",
|
|
"is_superuser",
|
|
"api_token",
|
|
"groups",
|
|
"notifications",
|
|
"date_joined",
|
|
"last_login",
|
|
]
|
|
search_fields = [
|
|
"username",
|
|
"first_name",
|
|
"last_name",
|
|
"email",
|
|
]
|
|
filter_horizontal = [
|
|
"groups",
|
|
"notifications",
|
|
]
|
|
readonly_fields = [
|
|
"date_joined",
|
|
"last_login",
|
|
]
|
|
autocomplete_fields = [
|
|
"api_token",
|
|
]
|
|
exclude = [
|
|
"user_permissions",
|
|
]
|
|
|
|
|
|
class UserActionLogEntryAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"id",
|
|
"user",
|
|
"timestamp",
|
|
"action",
|
|
]
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|
|
|
|
# Outcommented for a cleaner admin backend on production
|
|
#admin.site.register(UserNotification, UserNotificationAdmin)
|
|
#admin.site.register(UserActionLogEntry, UserActionLogEntryAdmin)
|