Documents: Remove old image caching model

With the creation of the new general use file Cache system
the old DocumentPageCachedImage model and manager are no longer
needed. This commit removed the model and the manager, and add
a migration to remove any data in the model before removing it
from the database.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-12-04 15:21:57 -04:00
parent 66b04296f5
commit f4e0e06c66
3 changed files with 34 additions and 51 deletions

View File

@@ -39,10 +39,9 @@ from .literals import (
DEFAULT_DELETE_PERIOD, DEFAULT_DELETE_TIME_UNIT, DOCUMENT_IMAGES_CACHE_NAME
)
from .managers import (
DocumentManager, DocumentPageCachedImage, DocumentPageManager,
DocumentVersionManager, DocumentTypeManager, DuplicatedDocumentManager,
FavoriteDocumentManager, PassthroughManager, RecentDocumentManager,
TrashCanManager
DocumentManager, DocumentPageManager, DocumentVersionManager,
DocumentTypeManager, DuplicatedDocumentManager, FavoriteDocumentManager,
PassthroughManager, RecentDocumentManager, TrashCanManager
)
from .permissions import permission_document_view
from .settings import (
@@ -972,38 +971,6 @@ class DocumentPage(models.Model):
return '{}-{}'.format(self.document_version.uuid, self.pk)
class DocumentPageCachedImage(models.Model):
document_page = models.ForeignKey(
on_delete=models.CASCADE, related_name='cached_images',
to=DocumentPage, verbose_name=_('Document page')
)
datetime = models.DateTimeField(
auto_now_add=True, db_index=True, verbose_name=_('Date time')
)
filename = models.CharField(max_length=128, verbose_name=_('Filename'))
file_size = models.PositiveIntegerField(
db_index=True, default=0, verbose_name=_('File size')
)
objects = DocumentPageCachedImage()
class Meta:
verbose_name = _('Document page cached image')
verbose_name_plural = _('Document page cached images')
#def delete(self, *args, **kwargs):
# storage_documentimagecache.delete(self.filename)
# return super(DocumentPageCachedImage, self).delete(*args, **kwargs)
def natural_key(self):
return (self.filename, self.document_page.natural_key())
natural_key.dependencies = ['documents.DocumentPage']
#def save(self, *args, **kwargs):
# self.file_size = storage_documentimagecache.size(self.filename)
# return super(DocumentPageCachedImage, self).save(*args, **kwargs)
class DocumentPageResult(DocumentPage):
class Meta:
ordering = ('document_version__document', 'page_number')