Browse Source

Funguje mazani, upravy a done/undone.

Lehce rozbite je zvyraznovani car,
chce to prozkoumat JS.
remotes/origin/opraf
parent
commit
4f1e04af99
  1. 17
      korektury/templates/korektury/opraf.html
  2. 47
      korektury/views.py

17
korektury/templates/korektury/opraf.html

@ -54,23 +54,28 @@
{% for o in opravy %} {% for o in opravy %}
<div onclick='img_click(this,event)' id='op{{o.id}}-pointer' class='pointer-done'></div> <div onclick='img_click(this,event)' id='op{{o.id}}-pointer' class='pointer{%if o.status = 'opraveno' %}-done{% endif %}'>
<div name='op{{o.id}}' id='op{{o.id}}' class='box-done' onmouseover='box_onmouseover(this,1)' onmouseout='box_onmouseout(this,1)' > </div>
<div name='op{{o.id}}' id='op{{o.id}}' class='box{%if o.status = 'opraveno' %}-done{% endif %}' onmouseover='box_onmouseover(this,1)' onmouseout='box_onmouseout(this,1)' >
<b>{{o.autor}}</b> <b>{{o.autor}}</b>
<div class='float-right'> <div class='float-right'>
<form action='' onsubmit='save_scroll(this)' method='POST'> <form action='' onsubmit='save_scroll(this)' method='POST'>
{% csrf_token %}
<input type='hidden' name='pdf' value='22_3_verze5.pdf'> <input type='hidden' name='pdf' value='22_3_verze5.pdf'>
<input type='hidden' name='id' value='op{{o.id}}'> <input type='hidden' name='id' value='{{o.id}}'>
<input type='hidden' name='scroll'> <input type='hidden' name='scroll'>
<button type='submit' name='action' value='del' title='Sma¾ opravu'><img src="/static/korektury/imgs/delete.png"/></button> <button type='submit' name='action' value='del' title='Sma¾ opravu'><img src="/static/korektury/imgs/delete.png"/></button>
{% if o.status = 'opraveno' %}
<button type='submit' name='action' value='undone' title='Oznaè jako neopravené'><img src="/static/korektury/imgs/undo.png"/></button> <button type='submit' name='action' value='undone' title='Oznaè jako neopravené'><img src="/static/korektury/imgs/undo.png"/></button>
{% else %}
<button type='submit' name='action' value='done' title='Oznaè jako opravené'><img src="/static/korektury/imgs/check.png"/></button>
{% endif %}
<button type='button' onclick='box_edit(this);' title='Oprav opravu'><img src="/static/korektury/imgs/edit.png"/></button> <button type='button' onclick='box_edit(this);' title='Oprav opravu'><img src="/static/korektury/imgs/edit.png"/></button>
<a href='#op578'><button type='button' title='Link na opravu'><img src="/static/korektury/imgs/link.png"/></button></a> <a href='#op{{o.id}}'><button type='button' title='Link na opravu'><img src="/static/korektury/imgs/link.png"/></button></a>
<a href='#op579'><img title='Dal¹í oprava' src="/static/korektury/imgs/next.png"/></button></a> <a href='#op579'><img title='Dal¹í oprava' src="/static/korektury/imgs/next.png"/></button></a>
</form> </form>
@ -94,4 +99,6 @@
{{ form_oprava.as_p }} {{ form_oprava.as_p }}
<input type='submit' value='Odeslat'/> <input type='submit' value='Odeslat'/>
</form> </form>
</body> </html> </body> </html>

47
korektury/views.py

@ -30,17 +30,46 @@ class KorekturyView(generic.TemplateView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
form = self.form_class(request.POST) form = self.form_class(request.POST)
q = request.POST q = request.POST
x = int(q.get('x'))
y = int(q.get('y'))
autor = q.get('au')
text = q.get('txt')
strana = int(q.get('img-id')[4:])
scroll = q.get('scroll')
oprava = Oprava(x=x,y=y, autor=autor, text=text, strana=strana)
oprava.save()
return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll)) action = q.get('action')
if (action == u''): # Přidej
x = int(q.get('x'))
y = int(q.get('y'))
autor = q.get('au')
text = q.get('txt')
strana = int(q.get('img-id')[4:])
scroll = q.get('scroll')
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana)
op.save()
elif (action == u'del'):
id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first()
op.delete()
elif (action == u'update'):
id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first()
autor = q.get('au')
text = q.get('txt')
op.autor = autor
op.text = text
op.save()
elif (action == u'undone'):
id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first()
op.status = op.STATUS_K_OPRAVE
op.save()
elif (action == u'done'):
id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first()
op.status = op.STATUS_OPRAVENO
op.save()
return HttpResponse(u'Oprav: %d, akce: %s'%(
len(Oprava.objects.all()),action))
# return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll))
# return render(request, 'seminar/opraf.html',self.get_context_data()) # return render(request, 'seminar/opraf.html',self.get_context_data())
# return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%( # return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%(
# len(Oprava.objects.all()),x,y,autor,text,strana)) # len(Oprava.objects.all()),x,y,autor,text,strana))

Loading…
Cancel
Save