mpeltriaux
e152dfd4d7
* adds team sharing field to share form * splits sharing logic into user based and teams based * adds TeamAdmin for admin backend * adds validity check on Team name -> only unused names shall be valid
85 lines
1.6 KiB
Python
85 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",
|
|
"admin",
|
|
]
|
|
search_fields = [
|
|
"name",
|
|
"description",
|
|
]
|
|
|
|
|
|
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)
|