Issue #56, remove print preview unused code

This commit is contained in:
Roberto Rosario
2014-10-13 17:08:23 -04:00
parent e26c6c1905
commit bcc71bebd2
4 changed files with 7 additions and 58 deletions

View File

@@ -290,7 +290,10 @@ class Document(models.Model):
@property
def first_version(self):
return self.versions.order_by('timestamp').first()
if self.pk not in self.__class__._first_versions:
self.__class__._first_versions[self.pk] = self.versions.order_by('timestamp').first()
return self.__class__._first_versions[self.pk]
def rename(self, new_name):
version = self.latest_version
@@ -503,6 +506,7 @@ class DocumentVersion(models.Model):
self.__class__._page_counts[self.pk] = None
# Invalidate parent document's latest version cache
Document._latest_versions[self.document.pk] = None
Document._first_versions[self.document.pk] = None
return super(DocumentVersion, self).delete(*args, **kwargs)