mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
![dependabot[bot]](/assets/img/avatar_default.png)
* Chore(deps-dev): Bump the development group with 2 updates Bumps the development group with 2 updates: [ruff](https://github.com/astral-sh/ruff) and [mkdocs-material](https://github.com/squidfunk/mkdocs-material). Updates `ruff` from 0.8.6 to 0.9.2 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.6...0.9.2) Updates `mkdocs-material` from 9.5.49 to 9.5.50 - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.49...9.5.50) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor dependency-group: development - dependency-name: mkdocs-material dependency-type: direct:development update-type: version-update:semver-patch dependency-group: development ... Signed-off-by: dependabot[bot] <support@github.com> * Update .pre-commit-config.yaml * Run new ruff format --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
89 lines
2.6 KiB
Python
89 lines
2.6 KiB
Python
import textwrap
|
|
|
|
from django.conf import settings
|
|
from django.core.checks import Error
|
|
from django.core.checks import Warning
|
|
from django.core.checks import register
|
|
from django.core.exceptions import FieldError
|
|
from django.db.utils import OperationalError
|
|
from django.db.utils import ProgrammingError
|
|
|
|
from documents.signals import document_consumer_declaration
|
|
from documents.templating.utils import convert_format_str_to_template_format
|
|
|
|
|
|
@register()
|
|
def changed_password_check(app_configs, **kwargs):
|
|
from documents.models import Document
|
|
from paperless.db import GnuPG
|
|
|
|
try:
|
|
encrypted_doc = (
|
|
Document.objects.filter(
|
|
storage_type=Document.STORAGE_TYPE_GPG,
|
|
)
|
|
.only("pk", "storage_type")
|
|
.first()
|
|
)
|
|
except (OperationalError, ProgrammingError, FieldError):
|
|
return [] # No documents table yet
|
|
|
|
if encrypted_doc:
|
|
if not settings.PASSPHRASE:
|
|
return [
|
|
Error(
|
|
"The database contains encrypted documents but no password is set.",
|
|
),
|
|
]
|
|
|
|
if not GnuPG.decrypted(encrypted_doc.source_file):
|
|
return [
|
|
Error(
|
|
textwrap.dedent(
|
|
"""
|
|
The current password doesn't match the password of the
|
|
existing documents.
|
|
|
|
If you intend to change your password, you must first export
|
|
all of the old documents, start fresh with the new password
|
|
and then re-import them."
|
|
""",
|
|
),
|
|
),
|
|
]
|
|
|
|
return []
|
|
|
|
|
|
@register()
|
|
def parser_check(app_configs, **kwargs):
|
|
parsers = []
|
|
for response in document_consumer_declaration.send(None):
|
|
parsers.append(response[1])
|
|
|
|
if len(parsers) == 0:
|
|
return [
|
|
Error(
|
|
"No parsers found. This is a bug. The consumer won't be "
|
|
"able to consume any documents without parsers.",
|
|
),
|
|
]
|
|
else:
|
|
return []
|
|
|
|
|
|
@register()
|
|
def filename_format_check(app_configs, **kwargs):
|
|
if settings.FILENAME_FORMAT:
|
|
converted_format = convert_format_str_to_template_format(
|
|
settings.FILENAME_FORMAT,
|
|
)
|
|
if converted_format != settings.FILENAME_FORMAT:
|
|
return [
|
|
Warning(
|
|
f"Filename format {settings.FILENAME_FORMAT} is using the old style, please update to use double curly brackets",
|
|
hint=converted_format,
|
|
),
|
|
]
|
|
return []
|