From c6890c487ab50ee324ff79eb02965cbf1dddec73 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 30 Mar 2016 01:32:53 -0400 Subject: [PATCH] Extract a file like object's file name as per docs (using the .name property) and not an unicode representation of the file object instance. Reference: https://docs.python.org/2.7/library/stdtypes.html#file-objects --- mayan/apps/documents/models.py | 4 ++-- mayan/apps/sources/models.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index e795bf74bf..ed605e11e4 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -127,7 +127,7 @@ class DocumentType(models.Model): with transaction.atomic(): document = self.documents.create( description=description or '', - label=label or unicode(file_object), + label=label or file_object.name, language=language or setting_language.value ) document.save(_user=_user) @@ -138,7 +138,7 @@ class DocumentType(models.Model): logger.critical( 'Unexpected exception while trying to create new document ' '"%s" from document type "%s"; %s', - label or unicode(file_object), self, exception + label or file_object.name, self, exception ) raise diff --git a/mayan/apps/sources/models.py b/mayan/apps/sources/models.py index 1e4baf9ebd..ed8cc90c6b 100644 --- a/mayan/apps/sources/models.py +++ b/mayan/apps/sources/models.py @@ -65,7 +65,7 @@ class Source(models.Model): with transaction.atomic(): document = Document.objects.create( description=description or '', document_type=document_type, - label=label or unicode(file_object), + label=label or file_object.name, language=language or setting_language.value ) document.save(_user=user) @@ -100,7 +100,7 @@ class Source(models.Model): logger.critical( 'Unexpected exception while trying to create new document ' '"%s" from source "%s"; %s', - label or unicode(file_object), self, exception + label or file_object.name, self, exception ) raise