Remove the get_filename_from_uuid helper function
This commit is contained in:
@@ -5,8 +5,9 @@ from django.db import models
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from django_gpg.runtime import gpg
|
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.runtime import storage_backend
|
||||||
|
from documents.settings import UUID_FUNCTION
|
||||||
|
|
||||||
from .managers import DocumentVersionSignatureManager
|
from .managers import DocumentVersionSignatureManager
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ class DocumentVersionSignature(models.Model):
|
|||||||
Model that describes a document version signature properties
|
Model that describes a document version signature properties
|
||||||
"""
|
"""
|
||||||
document_version = models.ForeignKey(DocumentVersion, verbose_name=_(u'Document version'), editable=False)
|
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)
|
has_embedded_signature = models.BooleanField(default=False, verbose_name=_(u'Has embedded signature'), editable=False)
|
||||||
|
|
||||||
objects = DocumentVersionSignatureManager()
|
objects = DocumentVersionSignatureManager()
|
||||||
|
|||||||
@@ -43,16 +43,6 @@ HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest() # document image cache
|
|||||||
logger = logging.getLogger(__name__)
|
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):
|
class DocumentType(models.Model):
|
||||||
"""
|
"""
|
||||||
Define document types or classes to which a specific set of
|
Define document types or classes to which a specific set of
|
||||||
@@ -259,11 +249,6 @@ class Document(models.Model):
|
|||||||
def file_mime_encoding(self):
|
def file_mime_encoding(self):
|
||||||
return self.latest_version.encoding
|
return self.latest_version.encoding
|
||||||
|
|
||||||
# TODO: Remove
|
|
||||||
@property
|
|
||||||
def file_filename(self):
|
|
||||||
return self.latest_version.filename
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def date_updated(self):
|
def date_updated(self):
|
||||||
return self.latest_version.timestamp
|
return self.latest_version.timestamp
|
||||||
@@ -328,7 +313,7 @@ class DocumentVersion(models.Model):
|
|||||||
comment = models.TextField(blank=True, verbose_name=_(u'Comment'))
|
comment = models.TextField(blank=True, verbose_name=_(u'Comment'))
|
||||||
|
|
||||||
# File related fields
|
# 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)
|
mimetype = models.CharField(max_length=255, null=True, blank=True, editable=False)
|
||||||
encoding = models.CharField(max_length=64, null=True, blank=True, editable=False)
|
encoding = models.CharField(max_length=64, null=True, blank=True, editable=False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user