mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
All attempts that are logged are marked as trusted and no other attempts are created in the code, so having a flag that also uses a database index is redundant and unnecessary. Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
106 lines
2.1 KiB
Python
106 lines
2.1 KiB
Python
from django.contrib import admin
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from axes.models import AccessAttempt, AccessLog
|
|
|
|
|
|
@admin.register(AccessAttempt)
|
|
class AccessAttemptAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'attempt_time',
|
|
'ip_address',
|
|
'user_agent',
|
|
'username',
|
|
'path_info',
|
|
'failures_since_start',
|
|
)
|
|
|
|
list_filter = [
|
|
'attempt_time',
|
|
'path_info',
|
|
]
|
|
|
|
search_fields = [
|
|
'ip_address',
|
|
'username',
|
|
'user_agent',
|
|
'path_info',
|
|
]
|
|
|
|
date_hierarchy = 'attempt_time'
|
|
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': ('path_info', 'failures_since_start')
|
|
}),
|
|
(_('Form Data'), {
|
|
'fields': ('get_data', 'post_data')
|
|
}),
|
|
(_('Meta Data'), {
|
|
'fields': ('user_agent', 'ip_address', 'http_accept')
|
|
})
|
|
)
|
|
|
|
readonly_fields = [
|
|
'user_agent',
|
|
'ip_address',
|
|
'username',
|
|
'http_accept',
|
|
'path_info',
|
|
'attempt_time',
|
|
'get_data',
|
|
'post_data',
|
|
'failures_since_start'
|
|
]
|
|
|
|
def has_add_permission(self, request):
|
|
return False
|
|
|
|
|
|
@admin.register(AccessLog)
|
|
class AccessLogAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'attempt_time',
|
|
'logout_time',
|
|
'ip_address',
|
|
'username',
|
|
'user_agent',
|
|
'path_info',
|
|
)
|
|
|
|
list_filter = [
|
|
'attempt_time',
|
|
'logout_time',
|
|
'path_info',
|
|
]
|
|
|
|
search_fields = [
|
|
'ip_address',
|
|
'user_agent',
|
|
'username',
|
|
'path_info',
|
|
]
|
|
|
|
date_hierarchy = 'attempt_time'
|
|
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': ('path_info',)
|
|
}),
|
|
(_('Meta Data'), {
|
|
'fields': ('user_agent', 'ip_address', 'http_accept')
|
|
})
|
|
)
|
|
|
|
readonly_fields = [
|
|
'user_agent',
|
|
'ip_address',
|
|
'username',
|
|
'http_accept',
|
|
'path_info',
|
|
'attempt_time',
|
|
'logout_time'
|
|
]
|
|
|
|
def has_add_permission(self, request):
|
|
return False
|