Changed setting name to AUDIT_LOG_ENABLED

This commit is contained in:
Aaron Katz 2023-10-24 17:27:07 +02:00
parent 5d4e22220d
commit 3732666bcf
5 changed files with 12 additions and 12 deletions

View File

@ -1138,7 +1138,7 @@ combination with PAPERLESS_CONSUMER_BARCODE_UPSCALE bigger than 1.0.
## Audit Trail
#### [`PAPERLESS_AUDIT_ENABLED=<bool>`](#PAPERLESS_AUDIT_ENABLED){#PAPERLESS_AUDIT_ENABLED}
#### [`PAPERLESS_AUDIT_LOG_ENABLED=<bool>`](#PAPERLESS_AUDIT_LOG_ENABLED){#PAPERLESS_AUDIT_LOG_ENABLED}
: Enables an audit trail for each document,document type, correspondent, and tag. This records all changes made to the documents to make the changes traceable.

View File

@ -13,7 +13,7 @@ from documents.models import ShareLink
from documents.models import StoragePath
from documents.models import Tag
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
from auditlog.admin import LogEntryAdmin
from auditlog.models import LogEntry
@ -154,7 +154,7 @@ admin.site.register(PaperlessTask, TaskAdmin)
admin.site.register(Note, NotesAdmin)
admin.site.register(ShareLink, ShareLinksAdmin)
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
class LogEntryAUDIT(LogEntryAdmin):
def has_delete_permission(self, request, obj=None):

View File

@ -20,7 +20,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from multiselectfield import MultiSelectField
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
from auditlog.registry import auditlog
from documents.data_models import DocumentSource
@ -877,7 +877,7 @@ class ConsumptionTemplate(models.Model):
return f"{self.name}"
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
auditlog.register(Document, m2m_fields={"tags"})
auditlog.register(Correspondent)
auditlog.register(Tag)

View File

@ -115,7 +115,7 @@ from paperless import version
from paperless.db import GnuPG
from paperless.views import StandardPagination
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
from auditlog.models import LogEntry
logger = logging.getLogger("paperless.api")
@ -526,7 +526,7 @@ class DocumentViewSet(
c.save()
# If audit log is enabled make an entry in the log
# about this note change
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
timezone.now()
LogEntry.objects.log_create(
instance=doc,
@ -562,7 +562,7 @@ class DocumentViewSet(
return HttpResponseForbidden("Insufficient permissions to delete")
note = Note.objects.get(id=int(request.GET.get("id")))
if settings.AUDIT_ENABLED:
if settings.AUDIT_LOG_ENABLED:
timezone.now()
LogEntry.objects.log_create(
instance=doc,

View File

@ -936,17 +936,17 @@ TIKA_GOTENBERG_ENDPOINT = os.getenv(
if TIKA_ENABLED:
INSTALLED_APPS.append("paperless_tika.apps.PaperlessTikaConfig")
AUDIT_ENABLED = __get_boolean("PAPERLESS_AUDIT_ENABLED", "NO")
if AUDIT_ENABLED:
AUDIT_LOG_ENABLED = __get_boolean("PAPERLESS_AUDIT_LOG_ENABLED", "NO")
if AUDIT_LOG_ENABLED:
INSTALLED_APPS.append("auditlog")
MIDDLEWARE.append("auditlog.middleware.AuditlogMiddleware")
db_conn = connections["default"]
all_tables = db_conn.introspection.table_names()
if ("auditlog_logentry" in all_tables) and not (AUDIT_ENABLED):
if ("auditlog_logentry" in all_tables) and not (AUDIT_LOG_ENABLED):
raise ImproperlyConfigured(
"auditlog table was found but PAPERLESS_AUDIT_ENABLED is not active.",
"auditlog table was found but PAPERLESS_AUDIT_LOG_ENABLED is not active.",
)