mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-21 20:09:23 +02:00
Enable auditlogging
This commit is contained in:
parent
a25dd16094
commit
349659be90
7 changed files with 210 additions and 67 deletions
|
@ -1,6 +1,25 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from .models import User, UserProfile
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import User, UserProfile, DomainApplication, Website
|
||||
|
||||
|
||||
class AuditedAdmin(admin.ModelAdmin):
|
||||
|
||||
"""Custom admin to make auditing easier."""
|
||||
|
||||
def history_view(self, request, object_id, extra_context=None):
|
||||
"""On clicking 'History', take admin to the auditlog view for an object."""
|
||||
return HttpResponseRedirect(
|
||||
"{url}?resource_type={content_type}&object_id={object_id}".format(
|
||||
url=reverse("admin:auditlog_logentry_changelist", args=()),
|
||||
content_type=ContentType.objects.get_for_model(self.model).pk,
|
||||
object_id=object_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class UserProfileInline(admin.StackedInline):
|
||||
|
@ -18,3 +37,5 @@ class MyUserAdmin(UserAdmin):
|
|||
|
||||
|
||||
admin.site.register(User, MyUserAdmin)
|
||||
admin.site.register(DomainApplication, AuditedAdmin)
|
||||
admin.site.register(Website, AuditedAdmin)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue