Legacy Migration
These instructions can be used to migrate a project using the legacy common_audit package to alliance_platform_audit.
The only structural change to the repository is that the render_audit_list
templatetag has been namespaced under alliance_platform.audit.
Note
If this is an older project that is not using the published alliance_platform packages at all you will need to
add the following to settings/base.py (at minimum) if no ALLIANCE_PLATFORM setting already exists:
ALLIANCE_PLATFORM = {
"CORE": {"PROJECT_DIR": PROJECT_DIR},
}
Follow these steps:
Check your
django-pghistoryversion is >= 3, upgrade if notInstall the
alliance_platform_auditpackage as per the installation instructions.Delete the
common_auditapp entirely fromdjango-root, and remove it fromINSTALLED_APPS.Remove
common_audit.test_common_auditfromTEST_APPSUpdate
AuditLogViewin<your_primary_app>/views/generic.pywith the latest from the template project to replace the permission identifiersReplace the following from
django_site/urls.py:from common_audit.api import AuditLogViewSet ... path("js-api/auditlog/", AuditLogViewSet.as_view()),
with
from alliance_platform.audit.api import AuditLogView from alliance_platform.audit.api import AuditUserChoicesView ... path("js-api/auditlog/", AuditLogView.as_view()), path("js-api/audit-user-choices/", AuditUserChoicesView.as_view(), name="audit_user_choices"),
Replace any imports from
common_audit.templatetags.auditwith imports fromalliance_platform.audit.templatetags.alliance_platform.audit.Replace all other imports from
common_auditwith imports fromalliance_platform.audit.Replace instances of
{% load audit %}in Django templates with{% load alliance_platform.audit %}Replace
common_auditwithalliance_platform_auditinPermissionMatrix.csv
Frontend
The render_audit_list templatetag is designed to be used with the @alliancesoftware/ui-audit/AuditLog
component by default. However, the audit/AuditLog.tsx component is (as of writing) still compatible
with the templatetag. If you wish to continue using the audit log component defined in your project,
make sure to set the AUDIT_LOG_COMPONENT_PATH to "audit/AuditLog" so the templatetag will
continue to render your project-specific audit log component.
You can also import useAuditEndpoint from @alliancesoftware/ui-audit to write your own audit
component, or integrate it into your existing audit component.