Return False for the document's exists() method when it doesn't have

a document version.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-06-30 17:47:01 -04:00
parent e46bf51022
commit 6a9c66ff3f

View File

@@ -237,7 +237,11 @@ class Document(models.Model):
Returns a boolean value that indicates if the document's
latest version file exists in storage
"""
return self.latest_version.exists()
latest_version = self.latest_version
if latest_version:
return latest_version.exists()
else:
return False
def invalidate_cache(self):
for document_version in self.versions.all():