mpeltriaux
8aa3fbd97a
* adds admin column on team index view * refactors Team model, so multiple members can become admins * adds team migration for switch from fkey->m2m structure * renames 'Group' to 'Permission' on user index view to avoid confusion between 'Groups' and Teams * adds new autocomplete route for team-admin selection based on already selected members of the TeamForm
88 lines
1.6 KiB
Python
88 lines
1.6 KiB
Python
from django.contrib import admin
|
|
|
|
from user.models import UserNotification, UserActionLogEntry, User, Team
|
|
|
|
|
|
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",
|
|
]
|
|
|
|
|
|
class TeamAdmin(admin.ModelAdmin):
|
|
list_display = [
|
|
"name",
|
|
"description",
|
|
]
|
|
search_fields = [
|
|
"name",
|
|
"description",
|
|
]
|
|
filter_horizontal = [
|
|
"users",
|
|
"admins",
|
|
]
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|
|
admin.site.register(Team, TeamAdmin)
|
|
|
|
# Outcommented for a cleaner admin backend on production
|
|
#admin.site.register(UserNotification, UserNotificationAdmin)
|
|
#admin.site.register(UserActionLogEntry, UserActionLogEntryAdmin)
|