mpeltriaux
8ff3cb9adc
* adds migrations for storing OAuthToken * adds OAuthToken model * adds OAuthToken admin * adds user migration for Fkey relation to OAuthToken
98 lines
1.8 KiB
Python
98 lines
1.8 KiB
Python
from django.contrib import admin
|
|
|
|
from konova.admin import DeletableObjectMixinAdmin
|
|
from user.models import 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",
|
|
"oauth_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(DeletableObjectMixinAdmin, admin.ModelAdmin):
|
|
list_display = [
|
|
"name",
|
|
"description",
|
|
"deleted",
|
|
]
|
|
search_fields = [
|
|
"name",
|
|
"description",
|
|
]
|
|
filter_horizontal = [
|
|
"users",
|
|
"admins",
|
|
]
|
|
|
|
readonly_fields = [
|
|
"deleted"
|
|
]
|
|
|
|
actions = [
|
|
"restore_deleted_data"
|
|
]
|
|
|
|
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)
|