Funkcni stav PDF.
Stav PDF se jiz da nastavit a pokud neni pridavani, tak upozornuje pri pridavani korektur.
This commit is contained in:
parent
9cc30ae304
commit
2f51d5c3cb
6 changed files with 60 additions and 4 deletions
|
@ -10,6 +10,7 @@ from django.utils.encoding import force_unicode
|
|||
from django.utils.text import slugify
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.cache import cache
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from imagekit.models import ImageSpecField, ProcessedImageField
|
||||
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)')
|
||||
|
||||
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)
|
||||
STATUS_PRIDAVANI = 'pridavani'
|
||||
|
@ -68,6 +69,14 @@ class KorekturovanePDF(models.Model):
|
|||
#TODO Nepovinný foreign key k číslu
|
||||
|
||||
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()
|
||||
print("\nSaving")
|
||||
print(self.pdf.path)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 347 B |
|
@ -1,6 +1,9 @@
|
|||
body{background: #f3f3f3; color: black;}
|
||||
body.locked {
|
||||
background: rgb(144, 189, 255);
|
||||
body.comitting {
|
||||
background: yellow;
|
||||
}
|
||||
body.deprecated {
|
||||
background: red;
|
||||
}
|
||||
|
||||
img{background:white;}
|
||||
|
|
|
@ -94,6 +94,17 @@ function close_commform() {
|
|||
|
||||
// show comment form, when clicked to image
|
||||
function img_click(element, ev) {
|
||||
var body_class = document.body.className;
|
||||
switch(body_class){
|
||||
case "comitting":
|
||||
if (!confirm("Právě jsou zanášeny korektury, opravdu chcete přidat novou?"))
|
||||
return;
|
||||
break;
|
||||
case "deprecated":
|
||||
if (!confirm("Toto PDF je již zastaralé, opravdu chcete vytvořit korekturu?"))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
var dx, dy;
|
||||
var par = element.parentNode;
|
||||
|
|
|
@ -5,8 +5,12 @@
|
|||
<script src="/static/korektury/opraf.js"></script>
|
||||
<title>Korektury {{pdf.nazev}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<body {% if pdf.status = 'zanaseni'%} class="comitting" {% elif pdf.status = 'zastarale' %} class="deprecated" {% endif %}>
|
||||
<h1>Korektury {{pdf.nazev}}</h1>
|
||||
{% if pdf.status = 'zanaseni' %} <h2> Probíhá zanášení korektur, zvažte, zda chcete přidávat nové </h2> {% endif %}
|
||||
{% if pdf.status = 'zastarale' %} <h2> Toto PDF je již zastaralé, nepřidávejte nové korektury </h2> {% endif %}
|
||||
<i>{{pdf.komentar}}</i>
|
||||
<br>
|
||||
<i>Klikni na chybu, napiš komentář</i> |
|
||||
<a href="/korektury">ls</a> |
|
||||
<a href="?action=doc">help</a> | |
|
||||
|
@ -54,6 +58,25 @@
|
|||
</form>
|
||||
<!-- /Smazat vsechny komentare !-->
|
||||
<hr/>
|
||||
<h4>Změnit stav PDF:</h4>
|
||||
<i>Aktuální: {{pdf.status}}</i>
|
||||
<br>
|
||||
<!-- Zmenit stav PDF !-->
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type='hidden' name='action' value='set-state'/>
|
||||
<input type='hidden' name='pdf' value='{{pdf.id}}'/>
|
||||
<input type="radio" name="state" value="adding" {% if pdf.status = 'pridavani' %} checked {% endif %}>Přidávání korektur
|
||||
<br>
|
||||
<input type="radio" name="state" value="comitting" {% if pdf.status = 'zanaseni' %} checked {% endif %}>Zanášení korektur
|
||||
<br>
|
||||
<input type="radio" name="state" value="deprecated" {% if pdf.status = 'zastarale' %} checked {% endif %}>Zastaralé, nekorigovat
|
||||
<br>
|
||||
<input type='submit' value='Změnit stav PDF'/>
|
||||
</form>
|
||||
|
||||
<!-- /Zmenit stav PDF !-->
|
||||
<hr/>
|
||||
<p>
|
||||
Děkujeme opravovatelům: {% for autor,pocet in zasluhy.items %} {{autor}}({{pocet}}) {% endfor %}</p>
|
||||
<hr>
|
||||
|
|
|
@ -105,6 +105,16 @@ class KorekturyView(generic.TemplateView):
|
|||
komentare = Komentar.objects.filter(oprava=opravy)
|
||||
opravy.delete()
|
||||
komentare.delete()
|
||||
elif (action == u'set-state'):
|
||||
pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
|
||||
if (q.get('state') == u'adding'):
|
||||
pdf.status = pdf.STATUS_PRIDAVANI
|
||||
elif (q.get('state') == u'comitting'):
|
||||
pdf.status = pdf.STATUS_ZANASENI
|
||||
elif (q.get('state') == u'deprecated'):
|
||||
pdf.status = pdf.STATUS_ZASTARALE
|
||||
pdf.save()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue