diff --git a/easyaudit/admin.py b/easyaudit/admin.py index 66f2914..e5b2d41 100644 --- a/easyaudit/admin.py +++ b/easyaudit/admin.py @@ -15,6 +15,7 @@ from .models import CRUDEvent, LoginEvent, RequestEvent from .admin_helpers import prettify_json, EasyAuditModelAdmin from .settings import (CRUD_EVENT_LIST_FILTER, LOGIN_EVENT_LIST_FILTER, REQUEST_EVENT_LIST_FILTER, + CRUD_EVENT_LIST_DISPLAY, LOGIN_EVENT_LIST_DISPLAY, REQUEST_EVENT_LIST_DISPLAY, CRUD_EVENT_SEARCH_FIELDS, LOGIN_EVENT_SEARCH_FIELDS, REQUEST_EVENT_SEARCH_FIELDS, READONLY_EVENTS) @@ -44,7 +45,7 @@ def export_to_csv(modeladmin, request, queryset): # CRUD events class CRUDEventAdmin(EasyAuditModelAdmin): - list_display = ['get_event_type_display', 'get_content_type', 'object_id', 'object_repr_link', 'user_link', 'datetime'] + list_display = CRUD_EVENT_LIST_DISPLAY date_hierarchy = 'datetime' list_filter = CRUD_EVENT_LIST_FILTER search_fields = CRUD_EVENT_SEARCH_FIELDS @@ -105,7 +106,7 @@ def changed_fields_prettified(self, obj): # Login events class LoginEventAdmin(EasyAuditModelAdmin): - list_display = ['datetime', 'get_login_type_display', 'user_link', "get_username", 'remote_ip'] + list_display = LOGIN_EVENT_LIST_DISPLAY date_hierarchy = 'datetime' list_filter = LOGIN_EVENT_LIST_FILTER search_fields = LOGIN_EVENT_SEARCH_FIELDS @@ -131,7 +132,7 @@ def get_username(self, obj): # Request events class RequestEventAdmin(EasyAuditModelAdmin): - list_display = ['datetime', 'user_link', 'method', 'url', 'remote_ip'] + list_display = REQUEST_EVENT_LIST_DISPLAY date_hierarchy = 'datetime' list_filter = REQUEST_EVENT_LIST_FILTER search_fields = REQUEST_EVENT_SEARCH_FIELDS diff --git a/easyaudit/settings.py b/easyaudit/settings.py index 2d5a367..fa338e0 100644 --- a/easyaudit/settings.py +++ b/easyaudit/settings.py @@ -109,6 +109,11 @@ def get_model_list(class_list): # which is however much costly when many rows are involved TRUNCATE_TABLE_SQL_STATEMENT = getattr(settings, 'DJANGO_EASY_AUDIT_TRUNCATE_TABLE_SQL_STATEMENT', '') +# Listview display configuration +CRUD_EVENT_LIST_DISPLAY = getattr(settings, 'DJANGO_EASY_AUDIT_CRUD_EVENT_LIST_DISPLAY', ['event_type', 'content_type', 'object_id', 'object_repr', 'user', 'datetime']) +LOGIN_EVENT_LIST_DISPLAY = getattr(settings, 'DJANGO_EASY_AUDIT_LOGIN_EVENT_LIST_DISPLAY', ['datetime', 'get_login_type_display', 'user_link', "get_username", 'remote_ip']) +REQUEST_EVENT_LIST_DISPLAY = getattr(settings, 'DJANGO_EASY_AUDIT_REQUEST_EVENT_LIST_DISPLAY', ['datetime', 'user_link', 'method', 'url', 'remote_ip']) + # Changeview filters configuration CRUD_EVENT_LIST_FILTER = getattr(settings, 'DJANGO_EASY_AUDIT_CRUD_EVENT_LIST_FILTER', ['event_type', 'content_type', 'user', 'datetime', ]) LOGIN_EVENT_LIST_FILTER = getattr(settings, 'DJANGO_EASY_AUDIT_LOGIN_EVENT_LIST_FILTER', ['login_type', 'user', 'datetime', ])