fix pdf upload

This commit is contained in:
j 2016-11-30 11:36:29 +01:00
parent 14bfb1a451
commit 6ad112a3b8

View file

@ -162,15 +162,20 @@ class Document(models.Model):
s.extension = self.extension
s.size = self.size
s.matches = self.matches
if self.extension == 'pdf':
s.dimensions = ox.sort_string('2') + ox.sort_string('%d' % self.pages)
prefix = 2
value = self.pages
else:
if self.extension == 'html':
resolution_sort = self.dimensions
s.dimensions = ox.sort_string('1') + ox.sort_string('%d' % resolution_sort)
prefix = 1
value = self.dimensions
else:
resolution_sort = self.width * self.height
s.dimensions = ox.sort_string('0') + ox.sort_string('%d' % resolution_sort)
prefix = 0
value = self.width * self.height
if value < 0:
value = 0
s.dimensions = ox.sort_string('%d' % prefix) + ox.sort_string('%d' % value)
def sortNames(values):
sort_value = u''
@ -260,7 +265,10 @@ class Document(models.Model):
if self.extension == 'html':
self.size = len(self.data.get('text', ''))
is_ready = not self.uploading and (self.file or self.extension == 'html')
if self.id:
if is_ready:
self.update_sort()
self.update_find()
self.update_facets()
@ -269,6 +277,7 @@ class Document(models.Model):
new = True
super(Document, self).save(*args, **kwargs)
if new:
if is_ready:
self.update_sort()
self.update_find()
self.update_facets()