|
@ -10,6 +10,7 @@ from django.utils.encoding import force_unicode |
|
|
from django.utils.text import slugify |
|
|
from django.utils.text import slugify |
|
|
from django.core.urlresolvers import reverse |
|
|
from django.core.urlresolvers import reverse |
|
|
from django.core.cache import cache |
|
|
from django.core.cache import cache |
|
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist |
|
|
from imagekit.models import ImageSpecField, ProcessedImageField |
|
|
from imagekit.models import ImageSpecField, ProcessedImageField |
|
|
from imagekit.processors import ResizeToFit, Transpose |
|
|
from imagekit.processors import ResizeToFit, Transpose |
|
|
|
|
|
|
|
@ -50,7 +51,7 @@ class KorekturovanePDF(models.Model): |
|
|
|
|
|
|
|
|
komentar = models.TextField(u'komentář k PDF',blank = True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)') |
|
|
komentar = models.TextField(u'komentář k PDF',blank = True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)') |
|
|
|
|
|
|
|
|
pdf = models.FileField(u'pdf', upload_to = generate_filename) |
|
|
pdf = models.FileField(u'PDF', upload_to = generate_filename) |
|
|
|
|
|
|
|
|
stran = models.IntegerField(u'počet stran', help_text = 'Počet stran PDF', default = 0) |
|
|
stran = models.IntegerField(u'počet stran', help_text = 'Počet stran PDF', default = 0) |
|
|
STATUS_PRIDAVANI = 'pridavani' |
|
|
STATUS_PRIDAVANI = 'pridavani' |
|
@ -68,6 +69,14 @@ class KorekturovanePDF(models.Model): |
|
|
#TODO Nepovinný foreign key k číslu |
|
|
#TODO Nepovinný foreign key k číslu |
|
|
|
|
|
|
|
|
def save(self): |
|
|
def save(self): |
|
|
|
|
|
# Pokud se nezmenilo PDF, tak nepregenerovavej nahledy |
|
|
|
|
|
try: |
|
|
|
|
|
original = KorekturovanePDF.objects.get(pk=self.pk) |
|
|
|
|
|
if original.pdf == self.pdf: |
|
|
|
|
|
super(KorekturovanePDF, self).save() |
|
|
|
|
|
return |
|
|
|
|
|
except ObjectDoesNotExist: |
|
|
|
|
|
pass |
|
|
super(KorekturovanePDF, self).save() |
|
|
super(KorekturovanePDF, self).save() |
|
|
print("\nSaving") |
|
|
print("\nSaving") |
|
|
print(self.pdf.path) |
|
|
print(self.pdf.path) |
|
|