Commits

funkybob  committed 2f1d818

Add RECENT_USERS setting

  • Participants
  • Parent commits 5afa36e

Comments (0)

Files changed (1)

File audittrail/admin.py

 from django.contrib.auth.models import User
 from django.db.models import Max
 
+from django.conf import settings
+
+RECENT_USERS = getattr(settings, 'AUDIT_RECENT_USERS', 20)
+
 class RecentlyActiveUser(SimpleListFilter):
     title = 'Most Recently Active'
     parameter_name = 'user'
             (user.pk, user.get_full_name() or user.username)
             for user in User.objects.annotate(
                 last_audit=Max('audit_events__created')
-            ).filter(last_audit__isnull=False).order_by('-last_audit')[:20]
+            ).filter(last_audit__isnull=False).order_by('-last_audit')[:RECENT_USERS]
         )
 
     def queryset(self, request, queryset):
     list_display = ('created', 'user', 'action', 'details',)
     list_filter = ('created', RecentlyActiveUser,)
     date_hierarchy = 'created'
+    search_fields = ('user__username', 'user__first_name', 'user__last_name', 'action', 'details',)
 
 admin.site.register(models.Audit, AuditAdmin)