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

Commit

Permalink
Don't run document checks if table doesn't exist yet
Browse files Browse the repository at this point in the history
  • Loading branch information
danielquinn committed May 28, 2018
1 parent 2ab2c37 commit 52b0249
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/documents/checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.checks import Warning, register
from django.db.utils import OperationalError


@register()
Expand All @@ -17,10 +18,12 @@ def changed_password_check(app_configs, **kwargs):
"re-import them."
)

document = Document.objects.order_by("-pk").filter(
storage_type=Document.STORAGE_TYPE_GPG
).first()
try:
document = Document.objects.order_by("-pk").filter(
storage_type=Document.STORAGE_TYPE_GPG).first()
if document and not GnuPG.decrypted(document.source_file):
return [Warning(warning.format(document))]
except OperationalError:
pass # No documents table yet

if document and not GnuPG.decrypted(document.source_file):
return [Warning(warning.format(document))]
return []

0 comments on commit 52b0249

Please sign in to comment.