Installation
Install the alliance_platform.audit package:
poetry add alliance_platform.audit
Add pgtrigger, pghistory, and alliance_platform.audit to your INSTALLED_APPS. If migrating from common_audit, pgtrigger and
pghistory will already be in installed_apps, and alliance_platform.audit should replace common_audit.
INSTALLED_APPS = [
...
'pgtrigger',
'pghistory',
'alliance_platform.audit',
...
]
Add
alliance_platform.audit.middleware.AuditMiddlewaretoMIDDLEWAREIn
urls.py, add paths foralliance_platform.audit.api.AuditLogViewandalliance_platform.audit.api.AuditUserChoicesView.
Frontend
If you want to use the pre-made audit log component (built off of @alliancesoftware/ui), you will need
to add @alliancesoftware/ui-audit to your package.json. By default, the render_audit_list
templatetag looks in this package to import the audit log component to display.
If you want to write your own audit log component, you can use the useAuditEndpoint hook from
@alliancesoftware/ui-audit to help interface between your component and the audit log endpoint.
This will work out of the box with the props passed from the render_audit_list template tag.
Other settings
All settings are optional, so you can omit this if the defaults are satisfactory.
In the settings file:
from alliance_platform.core.settings import AlliancePlatformCoreSettingsType
from alliance_platform.audit.settings import AlliancePlatformAuditSettingsType
class AlliancePlatformSettings(TypedDict):
CORE: AlliancePlatformCoreSettingsType
AUDIT: AlliancePlatformAuditSettingsType
# Any other settings for alliance_platform packages, e.g. FRONTEND
ALLIANCE_PLATFORM: AlliancePlatformSettings = {
"CORE": {"PROJECT_DIR": PROJECT_DIR},
"AUDIT": {
"LIST_PERM_ACTION": "audit",
"TRACK_IP_ADDRESS": True,
},
}