fix pdf upload
This commit is contained in:
parent
14bfb1a451
commit
6ad112a3b8
1 changed files with 21 additions and 12 deletions
|
@ -162,15 +162,20 @@ class Document(models.Model):
|
||||||
s.extension = self.extension
|
s.extension = self.extension
|
||||||
s.size = self.size
|
s.size = self.size
|
||||||
s.matches = self.matches
|
s.matches = self.matches
|
||||||
|
|
||||||
if self.extension == 'pdf':
|
if self.extension == 'pdf':
|
||||||
s.dimensions = ox.sort_string('2') + ox.sort_string('%d' % self.pages)
|
prefix = 2
|
||||||
|
value = self.pages
|
||||||
else:
|
else:
|
||||||
if self.extension == 'html':
|
if self.extension == 'html':
|
||||||
resolution_sort = self.dimensions
|
prefix = 1
|
||||||
s.dimensions = ox.sort_string('1') + ox.sort_string('%d' % resolution_sort)
|
value = self.dimensions
|
||||||
else:
|
else:
|
||||||
resolution_sort = self.width * self.height
|
prefix = 0
|
||||||
s.dimensions = ox.sort_string('0') + ox.sort_string('%d' % resolution_sort)
|
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):
|
def sortNames(values):
|
||||||
sort_value = u''
|
sort_value = u''
|
||||||
|
@ -260,7 +265,10 @@ class Document(models.Model):
|
||||||
if self.extension == 'html':
|
if self.extension == 'html':
|
||||||
self.size = len(self.data.get('text', ''))
|
self.size = len(self.data.get('text', ''))
|
||||||
|
|
||||||
|
is_ready = not self.uploading and (self.file or self.extension == 'html')
|
||||||
|
|
||||||
if self.id:
|
if self.id:
|
||||||
|
if is_ready:
|
||||||
self.update_sort()
|
self.update_sort()
|
||||||
self.update_find()
|
self.update_find()
|
||||||
self.update_facets()
|
self.update_facets()
|
||||||
|
@ -269,6 +277,7 @@ class Document(models.Model):
|
||||||
new = True
|
new = True
|
||||||
super(Document, self).save(*args, **kwargs)
|
super(Document, self).save(*args, **kwargs)
|
||||||
if new:
|
if new:
|
||||||
|
if is_ready:
|
||||||
self.update_sort()
|
self.update_sort()
|
||||||
self.update_find()
|
self.update_find()
|
||||||
self.update_facets()
|
self.update_facets()
|
||||||
|
|
Loading…
Reference in a new issue