Encapsulate in_trash field into is_in_trash symetric Document property
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -281,6 +281,10 @@ class Document(models.Model):
|
||||
for document_version in self.versions.all():
|
||||
document_version.invalidate_cache()
|
||||
|
||||
@property
|
||||
def is_in_trash(self):
|
||||
return self.in_trash
|
||||
|
||||
def natural_key(self):
|
||||
return (self.uuid,)
|
||||
natural_key.dependencies = ['documents.DocumentType']
|
||||
@@ -566,6 +570,10 @@ class DocumentVersion(models.Model):
|
||||
for page in self.pages.all():
|
||||
page.invalidate_cache()
|
||||
|
||||
@property
|
||||
def is_in_trash(self):
|
||||
return self.document.is_in_trash
|
||||
|
||||
def open(self, raw=False):
|
||||
"""
|
||||
Return a file descriptor to a document version's file irrespective of
|
||||
@@ -974,6 +982,10 @@ class DocumentPage(models.Model):
|
||||
for cached_image in self.cached_images.all():
|
||||
cached_image.delete()
|
||||
|
||||
@property
|
||||
def is_in_trash(self):
|
||||
return self.document.is_in_trash
|
||||
|
||||
def natural_key(self):
|
||||
return (self.page_number, self.document_version.natural_key())
|
||||
natural_key.dependencies = ['documents.DocumentVersion']
|
||||
|
||||
@@ -60,7 +60,7 @@ class DocumentPageThumbnailWidget(object):
|
||||
template_name='documents/widgets/document_thumbnail.html',
|
||||
context={
|
||||
# Disable the clickable link if the document is in the trash
|
||||
'disable_title_link': instance.in_trash,
|
||||
'disable_title_link': instance.is_in_trash,
|
||||
'gallery_name': 'document_list',
|
||||
'instance': instance,
|
||||
'size_preview_width': setting_preview_width.value,
|
||||
|
||||
Reference in New Issue
Block a user