diff --git a/mayan/apps/document_signatures/models.py b/mayan/apps/document_signatures/models.py index 19b90db01c..f80b3ce640 100644 --- a/mayan/apps/document_signatures/models.py +++ b/mayan/apps/document_signatures/models.py @@ -5,8 +5,9 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django_gpg.runtime import gpg -from documents.models import DocumentVersion, get_filename_from_uuid +from documents.models import DocumentVersion from documents.runtime import storage_backend +from documents.settings import UUID_FUNCTION from .managers import DocumentVersionSignatureManager @@ -18,7 +19,7 @@ class DocumentVersionSignature(models.Model): Model that describes a document version signature properties """ document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'Document version'), editable=False) - signature_file = models.FileField(blank=True, null=True, upload_to=get_filename_from_uuid, storage=storage_backend, verbose_name=_(u'Signature file'), editable=False) + signature_file = models.FileField(blank=True, null=True, upload_to=lambda: UUID_FUNCTION(), storage=storage_backend, verbose_name=_(u'Signature file'), editable=False) has_embedded_signature = models.BooleanField(default=False, verbose_name=_(u'Has embedded signature'), editable=False) objects = DocumentVersionSignatureManager() diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index e889e6af9c..0ad1cdebba 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -43,16 +43,6 @@ HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest() # document image cache logger = logging.getLogger(__name__) -# TODO :Remove, use lambda: UUID_FUNCTION() -def get_filename_from_uuid(instance, filename): - """ - Store the orignal filename of the uploaded file and replace it with - a UUID - """ - instance.filename = filename - return UUID_FUNCTION() - - class DocumentType(models.Model): """ Define document types or classes to which a specific set of @@ -259,11 +249,6 @@ class Document(models.Model): def file_mime_encoding(self): return self.latest_version.encoding - # TODO: Remove - @property - def file_filename(self): - return self.latest_version.filename - @property def date_updated(self): return self.latest_version.timestamp @@ -328,7 +313,7 @@ class DocumentVersion(models.Model): comment = models.TextField(blank=True, verbose_name=_(u'Comment')) # File related fields - file = models.FileField(upload_to=get_filename_from_uuid, storage=storage_backend, verbose_name=_(u'File')) + file = models.FileField(upload_to=lambda: UUID_FUNCTION(), storage=storage_backend, verbose_name=_(u'File')) mimetype = models.CharField(max_length=255, null=True, blank=True, editable=False) encoding = models.CharField(max_length=64, null=True, blank=True, editable=False)