2021-07-08 11:07:33 +02:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2022-05-30 15:38:16 +02:00
|
|
|
from konova.admin import DeletableObjectMixinAdmin
|
|
|
|
from user.models import User, Team
|
2021-07-08 17:23:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
class UserNotificationAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
|
|
|
"name",
|
|
|
|
"is_active",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-01-12 12:56:22 +01:00
|
|
|
class UserAdmin(admin.ModelAdmin):
|
2021-07-08 17:23:06 +02:00
|
|
|
list_display = [
|
2022-01-12 12:56:22 +01:00
|
|
|
"id",
|
|
|
|
"username",
|
|
|
|
"first_name",
|
|
|
|
"last_name",
|
|
|
|
"email",
|
2021-07-08 17:23:06 +02:00
|
|
|
]
|
2022-02-01 18:41:02 +01:00
|
|
|
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",
|
|
|
|
]
|
2021-07-08 17:23:06 +02:00
|
|
|
|
|
|
|
|
2021-07-29 15:49:19 +02:00
|
|
|
class UserActionLogEntryAdmin(admin.ModelAdmin):
|
|
|
|
list_display = [
|
|
|
|
"id",
|
|
|
|
"user",
|
|
|
|
"timestamp",
|
|
|
|
"action",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-05-30 15:38:16 +02:00
|
|
|
class TeamAdmin(DeletableObjectMixinAdmin, admin.ModelAdmin):
|
2022-02-18 11:02:40 +01:00
|
|
|
list_display = [
|
|
|
|
"name",
|
|
|
|
"description",
|
2022-05-30 15:38:16 +02:00
|
|
|
"deleted",
|
2022-02-18 11:02:40 +01:00
|
|
|
]
|
|
|
|
search_fields = [
|
|
|
|
"name",
|
|
|
|
"description",
|
|
|
|
]
|
2022-04-13 15:52:41 +02:00
|
|
|
filter_horizontal = [
|
2022-05-30 14:35:31 +02:00
|
|
|
"users",
|
|
|
|
"admins",
|
2022-04-13 15:52:41 +02:00
|
|
|
]
|
|
|
|
|
2022-05-30 15:38:16 +02:00
|
|
|
readonly_fields = [
|
|
|
|
"deleted"
|
|
|
|
]
|
|
|
|
|
|
|
|
actions = [
|
|
|
|
"restore_deleted_data"
|
|
|
|
]
|
2022-02-18 11:02:40 +01:00
|
|
|
|
2022-02-01 18:41:02 +01:00
|
|
|
admin.site.register(User, UserAdmin)
|
2022-02-18 11:02:40 +01:00
|
|
|
admin.site.register(Team, TeamAdmin)
|
2022-02-01 18:41:02 +01:00
|
|
|
|
|
|
|
# Outcommented for a cleaner admin backend on production
|
|
|
|
#admin.site.register(UserNotification, UserNotificationAdmin)
|
|
|
|
#admin.site.register(UserActionLogEntry, UserActionLogEntryAdmin)
|