Use old config var with default true
This commit is contained in:
parent
0a9c6ed07f
commit
527371dc36
@ -1309,11 +1309,11 @@ assigns or creates tags if a properly formatted barcode is detected.
|
|||||||
|
|
||||||
## Audit Trail
|
## Audit Trail
|
||||||
|
|
||||||
#### [`PAPERLESS_AUDIT_LOG_DISABLED=<bool>`](#PAPERLESS_AUDIT_LOG_DISABLED) {#PAPERLESS_AUDIT_LOG_DISABLED}
|
#### [`PAPERLESS_AUDIT_LOG_ENABLED=<bool>`](#PAPERLESS_AUDIT_LOG_ENABLED) {#PAPERLESS_AUDIT_LOG_ENABLED}
|
||||||
|
|
||||||
: Disables the audit trail for documents, document types, correspondents, and tags.
|
: Enables the audit trail for documents, document types, correspondents, and tags.
|
||||||
|
|
||||||
Defaults to false.
|
Defaults to true.
|
||||||
|
|
||||||
## Collate Double-Sided Documents {#collate}
|
## Collate Double-Sided Documents {#collate}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from documents.models import ShareLink
|
|||||||
from documents.models import StoragePath
|
from documents.models import StoragePath
|
||||||
from documents.models import Tag
|
from documents.models import Tag
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
from auditlog.admin import LogEntryAdmin
|
from auditlog.admin import LogEntryAdmin
|
||||||
from auditlog.models import LogEntry
|
from auditlog.models import LogEntry
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ admin.site.register(ShareLink, ShareLinksAdmin)
|
|||||||
admin.site.register(CustomField, CustomFieldsAdmin)
|
admin.site.register(CustomField, CustomFieldsAdmin)
|
||||||
admin.site.register(CustomFieldInstance, CustomFieldInstancesAdmin)
|
admin.site.register(CustomFieldInstance, CustomFieldInstancesAdmin)
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
|
|
||||||
class LogEntryAUDIT(LogEntryAdmin):
|
class LogEntryAUDIT(LogEntryAdmin):
|
||||||
def has_delete_permission(self, request, obj=None):
|
def has_delete_permission(self, request, obj=None):
|
||||||
|
@ -10,7 +10,7 @@ from typing import Optional
|
|||||||
import tqdm
|
import tqdm
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
from auditlog.models import LogEntry
|
from auditlog.models import LogEntry
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
@ -310,7 +310,7 @@ class Command(BaseCommand):
|
|||||||
serializers.serialize("json", ApplicationConfiguration.objects.all()),
|
serializers.serialize("json", ApplicationConfiguration.objects.all()),
|
||||||
)
|
)
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
manifest += json.loads(
|
manifest += json.loads(
|
||||||
serializers.serialize("json", LogEntry.objects.all()),
|
serializers.serialize("json", LogEntry.objects.all()),
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,7 @@ from documents.signals.handlers import update_filename_and_move_files
|
|||||||
from documents.utils import copy_file_with_basic_stats
|
from documents.utils import copy_file_with_basic_stats
|
||||||
from paperless import version
|
from paperless import version
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
from auditlog.registry import auditlog
|
from auditlog.registry import auditlog
|
||||||
|
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class Command(BaseCommand):
|
|||||||
receiver=update_filename_and_move_files,
|
receiver=update_filename_and_move_files,
|
||||||
sender=Document.tags.through,
|
sender=Document.tags.through,
|
||||||
):
|
):
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
auditlog.unregister(Document)
|
auditlog.unregister(Document)
|
||||||
auditlog.unregister(Correspondent)
|
auditlog.unregister(Correspondent)
|
||||||
auditlog.unregister(Tag)
|
auditlog.unregister(Tag)
|
||||||
|
@ -20,7 +20,7 @@ from django.utils import timezone
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from multiselectfield import MultiSelectField
|
from multiselectfield import MultiSelectField
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
from auditlog.registry import auditlog
|
from auditlog.registry import auditlog
|
||||||
|
|
||||||
from documents.data_models import DocumentSource
|
from documents.data_models import DocumentSource
|
||||||
@ -881,7 +881,7 @@ class CustomFieldInstance(models.Model):
|
|||||||
raise NotImplementedError(self.field.data_type)
|
raise NotImplementedError(self.field.data_type)
|
||||||
|
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
auditlog.register(Document, m2m_fields={"tags"})
|
auditlog.register(Document, m2m_fields={"tags"})
|
||||||
auditlog.register(Correspondent)
|
auditlog.register(Correspondent)
|
||||||
auditlog.register(Tag)
|
auditlog.register(Tag)
|
||||||
|
@ -43,7 +43,7 @@ from documents.plugins.helpers import ProgressStatusOptions
|
|||||||
from documents.sanity_checker import SanityCheckFailedException
|
from documents.sanity_checker import SanityCheckFailedException
|
||||||
from documents.signals import document_updated
|
from documents.signals import document_updated
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from auditlog.models import LogEntry
|
from auditlog.models import LogEntry
|
||||||
@ -275,7 +275,7 @@ def update_document_archive_file(document_id):
|
|||||||
archive_filename=document.archive_filename,
|
archive_filename=document.archive_filename,
|
||||||
)
|
)
|
||||||
newDocument = Document.objects.get(pk=document.pk)
|
newDocument = Document.objects.get(pk=document.pk)
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
LogEntry.objects.log_create(
|
LogEntry.objects.log_create(
|
||||||
instance=oldDocument,
|
instance=oldDocument,
|
||||||
changes=json.dumps(
|
changes=json.dumps(
|
||||||
|
@ -789,7 +789,7 @@ class TestExportImport(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with override_settings(
|
with override_settings(
|
||||||
AUDIT_LOG_DISABLED=True,
|
AUDIT_LOG_ENABLED=False,
|
||||||
):
|
):
|
||||||
manifest = self._do_export(use_filename_format=True)
|
manifest = self._do_export(use_filename_format=True)
|
||||||
for obj in manifest:
|
for obj in manifest:
|
||||||
|
@ -153,7 +153,7 @@ from paperless.config import GeneralConfig
|
|||||||
from paperless.db import GnuPG
|
from paperless.db import GnuPG
|
||||||
from paperless.views import StandardPagination
|
from paperless.views import StandardPagination
|
||||||
|
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
from auditlog.models import LogEntry
|
from auditlog.models import LogEntry
|
||||||
|
|
||||||
logger = logging.getLogger("paperless.api")
|
logger = logging.getLogger("paperless.api")
|
||||||
@ -636,7 +636,7 @@ class DocumentViewSet(
|
|||||||
c.save()
|
c.save()
|
||||||
# If audit log is enabled make an entry in the log
|
# If audit log is enabled make an entry in the log
|
||||||
# about this note change
|
# about this note change
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
LogEntry.objects.log_create(
|
LogEntry.objects.log_create(
|
||||||
instance=doc,
|
instance=doc,
|
||||||
changes=json.dumps(
|
changes=json.dumps(
|
||||||
@ -671,7 +671,7 @@ class DocumentViewSet(
|
|||||||
return HttpResponseForbidden("Insufficient permissions to delete notes")
|
return HttpResponseForbidden("Insufficient permissions to delete notes")
|
||||||
|
|
||||||
note = Note.objects.get(id=int(request.GET.get("id")))
|
note = Note.objects.get(id=int(request.GET.get("id")))
|
||||||
if not settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
LogEntry.objects.log_create(
|
LogEntry.objects.log_create(
|
||||||
instance=doc,
|
instance=doc,
|
||||||
changes=json.dumps(
|
changes=json.dumps(
|
||||||
|
@ -204,10 +204,10 @@ def audit_log_check(app_configs, **kwargs):
|
|||||||
all_tables = db_conn.introspection.table_names()
|
all_tables = db_conn.introspection.table_names()
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
if ("auditlog_logentry" in all_tables) and (settings.AUDIT_LOG_DISABLED):
|
if ("auditlog_logentry" in all_tables) and not settings.AUDIT_LOG_ENABLED:
|
||||||
result.append(
|
result.append(
|
||||||
Warning(
|
Warning(
|
||||||
("auditlog table was found but AUDIT_LOG_DISABLED is active."),
|
("auditlog table was found but audit log is disabled."),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1045,8 +1045,8 @@ TIKA_GOTENBERG_ENDPOINT = os.getenv(
|
|||||||
if TIKA_ENABLED:
|
if TIKA_ENABLED:
|
||||||
INSTALLED_APPS.append("paperless_tika.apps.PaperlessTikaConfig")
|
INSTALLED_APPS.append("paperless_tika.apps.PaperlessTikaConfig")
|
||||||
|
|
||||||
AUDIT_LOG_DISABLED = __get_boolean("PAPERLESS_AUDIT_LOG_DISABLED", "NO")
|
AUDIT_LOG_ENABLED = __get_boolean("PAPERLESS_AUDIT_LOG_ENABLED", "true")
|
||||||
if not AUDIT_LOG_DISABLED:
|
if AUDIT_LOG_ENABLED:
|
||||||
INSTALLED_APPS.append("auditlog")
|
INSTALLED_APPS.append("auditlog")
|
||||||
MIDDLEWARE.append("auditlog.middleware.AuditlogMiddleware")
|
MIDDLEWARE.append("auditlog.middleware.AuditlogMiddleware")
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ class TestAuditLogChecks(TestCase):
|
|||||||
"""
|
"""
|
||||||
introspect_mock = mock.MagicMock()
|
introspect_mock = mock.MagicMock()
|
||||||
introspect_mock.introspection.table_names.return_value = ["auditlog_logentry"]
|
introspect_mock.introspection.table_names.return_value = ["auditlog_logentry"]
|
||||||
with override_settings(AUDIT_LOG_DISABLED=True):
|
with override_settings(AUDIT_LOG_ENABLED=False):
|
||||||
with mock.patch.dict(
|
with mock.patch.dict(
|
||||||
"paperless.checks.connections",
|
"paperless.checks.connections",
|
||||||
{"default": introspect_mock},
|
{"default": introspect_mock},
|
||||||
@ -259,6 +259,6 @@ class TestAuditLogChecks(TestCase):
|
|||||||
msg = msgs[0]
|
msg = msgs[0]
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
("auditlog table was found but AUDIT_LOG_DISABLED is active."),
|
("auditlog table was found but audit log is disabled."),
|
||||||
msg.msg,
|
msg.msg,
|
||||||
)
|
)
|
||||||
|
@ -17,8 +17,8 @@ omit =
|
|||||||
|
|
||||||
[coverage:report]
|
[coverage:report]
|
||||||
exclude_also =
|
exclude_also =
|
||||||
if settings.AUDIT_LOG_DISABLED:
|
if settings.AUDIT_LOG_ENABLED:
|
||||||
if AUDIT_LOG_DISABLED:
|
if AUDIT_LOG_ENABLED:
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user