2008-11-05 22:52:40 +00:00
|
|
|
from django.contrib import admin
|
2018-07-17 13:57:24 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2020-09-12 13:18:47 +00:00
|
|
|
from axes.conf import settings
|
2019-02-10 20:01:08 +00:00
|
|
|
from axes.models import AccessAttempt, AccessLog
|
2008-11-05 22:52:40 +00:00
|
|
|
|
2011-04-12 21:04:51 +00:00
|
|
|
|
2008-11-05 22:52:40 +00:00
|
|
|
class AccessAttemptAdmin(admin.ModelAdmin):
|
2013-03-16 22:13:35 +00:00
|
|
|
list_display = (
|
2019-09-28 16:27:50 +00:00
|
|
|
"attempt_time",
|
|
|
|
|
"ip_address",
|
|
|
|
|
"user_agent",
|
|
|
|
|
"username",
|
|
|
|
|
"path_info",
|
|
|
|
|
"failures_since_start",
|
2013-03-16 22:13:35 +00:00
|
|
|
)
|
|
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
list_filter = ["attempt_time", "path_info"]
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
search_fields = ["ip_address", "username", "user_agent", "path_info"]
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
date_hierarchy = "attempt_time"
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2008-11-05 22:52:40 +00:00
|
|
|
fieldsets = (
|
2019-09-28 16:27:50 +00:00
|
|
|
(None, {"fields": ("path_info", "failures_since_start")}),
|
|
|
|
|
(_("Form Data"), {"fields": ("get_data", "post_data")}),
|
|
|
|
|
(_("Meta Data"), {"fields": ("user_agent", "ip_address", "http_accept")}),
|
2008-11-05 22:52:40 +00:00
|
|
|
)
|
|
|
|
|
|
2016-08-18 10:11:28 +00:00
|
|
|
readonly_fields = [
|
2019-09-28 16:27:50 +00:00
|
|
|
"user_agent",
|
|
|
|
|
"ip_address",
|
|
|
|
|
"username",
|
|
|
|
|
"http_accept",
|
|
|
|
|
"path_info",
|
|
|
|
|
"attempt_time",
|
|
|
|
|
"get_data",
|
|
|
|
|
"post_data",
|
|
|
|
|
"failures_since_start",
|
2016-08-18 10:11:28 +00:00
|
|
|
]
|
|
|
|
|
|
2018-04-20 21:01:43 +00:00
|
|
|
def has_add_permission(self, request):
|
2016-08-18 10:11:28 +00:00
|
|
|
return False
|
|
|
|
|
|
2018-05-26 17:28:11 +00:00
|
|
|
|
2012-11-25 20:46:45 +00:00
|
|
|
class AccessLogAdmin(admin.ModelAdmin):
|
2013-03-16 22:13:35 +00:00
|
|
|
list_display = (
|
2019-09-28 16:27:50 +00:00
|
|
|
"attempt_time",
|
|
|
|
|
"logout_time",
|
|
|
|
|
"ip_address",
|
|
|
|
|
"username",
|
|
|
|
|
"user_agent",
|
|
|
|
|
"path_info",
|
2013-03-16 22:13:35 +00:00
|
|
|
)
|
|
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
list_filter = ["attempt_time", "logout_time", "path_info"]
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
search_fields = ["ip_address", "user_agent", "username", "path_info"]
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2019-09-28 16:27:50 +00:00
|
|
|
date_hierarchy = "attempt_time"
|
2013-03-16 22:13:35 +00:00
|
|
|
|
2012-11-25 20:46:45 +00:00
|
|
|
fieldsets = (
|
2019-09-28 16:27:50 +00:00
|
|
|
(None, {"fields": ("path_info",)}),
|
|
|
|
|
(_("Meta Data"), {"fields": ("user_agent", "ip_address", "http_accept")}),
|
2012-11-25 20:46:45 +00:00
|
|
|
)
|
|
|
|
|
|
2016-08-18 10:11:28 +00:00
|
|
|
readonly_fields = [
|
2019-09-28 16:27:50 +00:00
|
|
|
"user_agent",
|
|
|
|
|
"ip_address",
|
|
|
|
|
"username",
|
|
|
|
|
"http_accept",
|
|
|
|
|
"path_info",
|
|
|
|
|
"attempt_time",
|
|
|
|
|
"logout_time",
|
2016-08-18 10:11:28 +00:00
|
|
|
]
|
|
|
|
|
|
2018-04-20 21:01:43 +00:00
|
|
|
def has_add_permission(self, request):
|
2016-08-18 10:11:28 +00:00
|
|
|
return False
|
2019-10-09 16:02:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if settings.AXES_ENABLE_ADMIN:
|
|
|
|
|
admin.site.register(AccessAttempt, AccessAttemptAdmin)
|
|
|
|
|
admin.site.register(AccessLog, AccessLogAdmin)
|