Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
add some more checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Winkler committed Nov 12, 2020
1 parent 2e04ba1 commit 0421031
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/documents/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.core.checks import Error, register
from django.db.utils import OperationalError, ProgrammingError

from documents.signals import document_consumer_declaration


@register()
def changed_password_check(app_configs, **kwargs):
Expand Down Expand Up @@ -37,3 +39,17 @@ def changed_password_check(app_configs, **kwargs):
"""))]

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 onsume any documents without parsers.")]
else:
return []
2 changes: 0 additions & 2 deletions src/documents/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def get_parser_class(doc):
for response in document_consumer_declaration.send(None):
parsers.append(response[1])

# TODO: add a check that checks parser availability.

options = []
for parser in parsers:
result = parser(doc)
Expand Down
13 changes: 13 additions & 0 deletions src/paperless/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,16 @@ def binaries_check(app_configs, **kwargs):
check_messages.append(Warning(error.format(binary), hint))

return check_messages


@register()
def debug_mode_check(app_configs, **kwargs):
if settings.DEBUG:
return [Warning("DEBUG mode is enabled. Disable Debug mode. "
"This is a serious security "
"issue, since it puts security overides in place which"
"are meant to be only used during development. This"
"also means that paperless will tell anyone various"
"debugging information when something goes wrong.")]
else:
return []

0 comments on commit 0421031

Please sign in to comment.