Browse Source

Skryvani korektur.

remotes/origin/opraf
parent
commit
e66f8c43be
  1. BIN
      korektury/static/korektury/imgs/hide.png
  2. 14
      korektury/static/korektury/opraf.js
  3. 11
      korektury/templates/korektury/opraf.html
  4. 2
      korektury/templates/korektury/seznam.html
  5. 20
      korektury/views.py

BIN
korektury/static/korektury/imgs/hide.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

14
korektury/static/korektury/opraf.js

@ -122,6 +122,20 @@ function img_click(element, ev) {
} }
return show_form(img_id, dx, dy, '', '', '', ''); return show_form(img_id, dx, dy, '', '', '', '');
} }
// hide or show text of correction
function toggle_visibility(button){
var divbox = button.parentNode.parentNode.parentNode;
var id = divbox.id;
var text = document.getElementById(id+'-text');
if (text.style.display == 'none'){
text.style.display = 'block';
}else {
text.style.display = 'none';
}
for (var i=0;i<comments.length-1;i++){
place_comments_one_div(comments[i][0], comments[i][1])
}
}
// show comment form, when 'edit' or 'comment' button pressed // show comment form, when 'edit' or 'comment' button pressed
function box_edit(button, action) function box_edit(button, action)

11
korektury/templates/korektury/opraf.html

@ -144,6 +144,10 @@
<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'> <button type='button' onclick='box_edit(this, "comment");' title='Komentovat'>
<img src="{% static "korektury/imgs/comment.png" %}"/> <img src="{% static "korektury/imgs/comment.png" %}"/>
</button> </button>
<button type='button' onclick='toggle_visibility(this);' title='Skrýt/Zobrazit'>
<img src="{% static "korektury/imgs/hide.png" %}"/>
</button>
</div> </div>
</div> </div>
<div id='op{{o.id}}-text'>{{o.text}}</div> <div id='op{{o.id}}-text'>{{o.text}}</div>
@ -178,9 +182,14 @@
{% endfor %} {% endfor %}
<script> <script>
var comments = [
{% for s in opravy_strany %} {% for s in opravy_strany %}
place_comments_one_div("img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]); ["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
{% endfor %} {% endfor %}
[]]
for (var i=0;i<comments.length-1;i++){
place_comments_one_div(comments[i][0], comments[i][1])
}
{% if scroll %} {% if scroll %}
window.scrollTo(0,{{scroll}}); window.scrollTo(0,{{scroll}});
{% endif %} {% endif %}

2
korektury/templates/korektury/seznam.html

@ -12,7 +12,7 @@
<ul> <ul>
{% for pdf in object_list %} {% for pdf in object_list %}
<li> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.url}}</a> </li> <li> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a> </li>
{% empty %} {% empty %}
<li> Nejsou žádné dokumenty ke korekturování. <li> Nejsou žádné dokumenty ke korekturování.
{% endfor %} {% endfor %}

20
korektury/views.py

@ -43,52 +43,52 @@ class KorekturyView(generic.TemplateView):
y = int(q.get('y')) y = int(q.get('y'))
text = q.get('txt') text = q.get('txt')
strana = int(q.get('img-id')[4:]) strana = int(q.get('img-id')[4:])
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')).first() pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
op.save() op.save()
elif (action == u'del'): elif (action == u'del'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.delete() op.delete()
elif (action == u'update'): elif (action == u'update'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
op.autor = autor op.autor = autor
op.text = text op.text = text
op.save() op.save()
elif (action == u'undone'): elif (action == u'undone'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_K_OPRAVE op.status = op.STATUS_K_OPRAVE
op.save() op.save()
elif (action == u'done'): elif (action == u'done'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_OPRAVENO op.status = op.STATUS_OPRAVENO
op.save() op.save()
elif (action == u'wontfix'): elif (action == u'wontfix'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_NENI_CHYBA op.status = op.STATUS_NENI_CHYBA
op.save() op.save()
elif (action == u'comment'): elif (action == u'comment'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom = Komentar(oprava=op,autor=autor,text=text) kom = Komentar(oprava=op,autor=autor,text=text)
kom.save() kom.save()
elif (action == u'update-comment'): elif (action == u'update-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first() kom = Komentar.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom.text = text kom.text = text
kom.autor = autor kom.autor = autor
kom.save() kom.save()
elif (action == u'del-comment'): elif (action == u'del-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first() kom = Komentar.objects.get(id=id)
kom.delete() kom.delete()
elif (action == u'delall'): elif (action == u'delall'):
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')) pdf = KorekturovanePDF.objects.filter(id=q.get('pdf'))
@ -114,7 +114,7 @@ class KorekturyView(generic.TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(KorekturyView,self).get_context_data(**kwargs) context = super(KorekturyView,self).get_context_data(**kwargs)
pdf = KorekturovanePDF.objects.filter(id=self.kwargs['pdf']).first() pdf = KorekturovanePDF.objects.get(id=self.kwargs['pdf'])
context['pdf'] = pdf context['pdf'] = pdf
context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0] context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0]
context['img_path'] = settings.KOREKTURY_IMG_DIR context['img_path'] = settings.KOREKTURY_IMG_DIR

Loading…
Cancel
Save