diff --git a/apps/documents/admin.py b/apps/documents/admin.py index ff4aa33cb0..71d0fab939 100644 --- a/apps/documents/admin.py +++ b/apps/documents/admin.py @@ -35,7 +35,7 @@ class DocumentAdmin(admin.ModelAdmin): inlines = [ DocumentMetadataInline, DocumentPageInline ] - list_display = ('uuid', 'file_filename', 'file_extension') + list_display = ('uuid', 'file_filename',) class RecentDocumentAdmin(admin.ModelAdmin): diff --git a/apps/documents/models.py b/apps/documents/models.py index 914426a568..14117269a0 100644 --- a/apps/documents/models.py +++ b/apps/documents/models.py @@ -46,10 +46,7 @@ def get_filename_from_uuid(instance, filename): Store the orignal filename of the uploaded file and replace it with a UUID """ - filename, extension = os.path.splitext(filename) instance.file_filename = filename - #remove prefix '.' - instance.file_extension = extension[1:] uuid = UUID_FUNCTION() instance.uuid = uuid return uuid @@ -82,7 +79,6 @@ class Document(models.Model): file_mime_encoding = models.CharField(max_length=64, default='', editable=False) #FAT filename can be up to 255 using LFN file_filename = models.CharField(max_length=255, default=u'', editable=False, db_index=True) - file_extension = models.CharField(max_length=16, default=u'', editable=False, db_index=True) date_added = models.DateTimeField(verbose_name=_(u'added'), auto_now_add=True, db_index=True) date_updated = models.DateTimeField(verbose_name=_(u'updated'), auto_now=True) checksum = models.TextField(blank=True, null=True, verbose_name=_(u'checksum'), editable=False) @@ -102,7 +98,7 @@ class Document(models.Model): ordering = ['-date_added'] def __unicode__(self): - return os.extsep.join([self.file_filename, self.file_extension]) + return self.get_fullname() def save(self, *args, **kwargs): """ @@ -130,7 +126,7 @@ class Document(models.Model): """ Return the fullname of the document's file """ - return os.extsep.join([self.file_filename, self.file_extension]) + return self.file_filename def update_mimetype(self, save=True): """ @@ -420,7 +416,6 @@ register('document', Document, _(u'document'), [ {'name': u'document_type__name', 'title': _(u'Document type')}, {'name': u'file_mimetype', 'title': _(u'MIME type')}, {'name': u'file_filename', 'title': _(u'Filename')}, - {'name': u'file_extension', 'title': _(u'Filename extension')}, {'name': u'documentmetadata__value', 'title': _(u'Metadata value')}, {'name': u'documentpage__content', 'title': _(u'Content')}, {'name': u'description', 'title': _(u'Description')}, @@ -428,4 +423,4 @@ register('document', Document, _(u'document'), [ {'name': u'comments__comment', 'title': _(u'Comments')}, ] ) -#register(Document, _(u'document'), ['document_type__name', 'file_mimetype', 'file_extension', 'documentmetadata__value', 'documentpage__content', 'description', {'field_name':'file_filename', 'comparison':'iexact'}]) +#register(Document, _(u'document'), ['document_type__name', 'file_mimetype', 'documentmetadata__value', 'documentpage__content', 'description', {'field_name':'file_filename', 'comparison':'iexact'}]) diff --git a/apps/documents/views.py b/apps/documents/views.py index 60a03ee74c..68a70f2435 100644 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -65,7 +65,7 @@ def document_list(request, object_list=None, title=None, extra_context=None): check_permissions(request.user, [PERMISSION_DOCUMENT_VIEW]) context = { - 'object_list': object_list if not (object_list is None) else Document.objects.only('file_filename', 'file_extension').all(), + 'object_list': object_list if not (object_list is None) else Document.objects.only('file_filename',).all(), 'title': title if title else _(u'documents'), 'multi_select_as_buttons': True, 'hide_links': True, @@ -115,7 +115,6 @@ def document_view(request, document_id, advanced=False): if advanced: document_properties_form = DocumentPropertiesForm(instance=document, extra_fields=[ {'label': _(u'Filename'), 'field': 'file_filename'}, - {'label': _(u'File extension'), 'field': 'file_extension'}, {'label': _(u'File mimetype'), 'field': 'file_mimetype'}, {'label': _(u'File mime encoding'), 'field': 'file_mime_encoding'}, {'label': _(u'File size'), 'field':lambda x: pretty_size(x.size) if x.size else '-'}, @@ -482,7 +481,7 @@ def document_update_page_count(request): previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', '/'))) office_converter = OfficeConverter() - qs = Document.objects.exclude(file_extension__iendswith='dxf').filter(file_mimetype__in=office_converter.mimetypes()) + qs = Document.objects.exclude(file_filename__iendswith='dxf').filter(file_mimetype__in=office_converter.mimetypes()) if request.method == 'POST': updated = 0