Pridano ruseni vsech komentaru, zasluhy a pamet autora.
Vetsina formularu si pamatuje posledniho autora. Nefunguje editace, ale aspon se zobrazi okno.
This commit is contained in:
parent
b0f9714329
commit
0915838f26
2 changed files with 51 additions and 17 deletions
|
@ -17,9 +17,9 @@
|
|||
<div id="commform-div">
|
||||
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST">
|
||||
{% csrf_token %}
|
||||
<input size="8" name="au" value="anonym"/>
|
||||
<input size="8" name="au" value="{{autor}}"/>
|
||||
<input type=submit value="Oprav!"/>
|
||||
<button type="button" onclick="close_commform()">Zavøít</button>
|
||||
<button type="button" onclick="close_commform()">Zavřít</button>
|
||||
<br/>
|
||||
<textarea onkeypress="textarea_onkey(event);" id="commform-text" cols=40 rows=10 name="txt"></textarea>
|
||||
<br/>
|
||||
|
@ -38,16 +38,15 @@
|
|||
{% endfor %}
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type='hidden' name='action' value='delall'/>
|
||||
<input type='submit' value='Smazat v¹echny komentáøe'/>
|
||||
<input type='submit' value='Smazat všechny komentáře'/>
|
||||
<input type='hidden' name='pdf' value='{{pdf.id}}'/>
|
||||
<input type='checkbox' name='yes'/> Souhlasím se smazáním v¹ech kometáøù
|
||||
<input type='checkbox' name='yes'/> Souhlasím se smazáním všech kometářů
|
||||
</form>
|
||||
<hr/>
|
||||
|
||||
Dìkujeme opravovatelùm: Marble(4), zuzka(4), Matìj(2), O(N)dra(2), Va¹ek(1), Kristý(1), Tonda(1), Jethro(1), Pe»a(1), ML(1), Lucka(1) <hr>
|
||||
|
||||
|
||||
Děkujeme opravovatelům: {% for autor,pocet in zasluhy.items %} {{autor}}({{pocet}}) {% endfor %}<hr>
|
||||
|
||||
|
||||
|
||||
|
@ -64,7 +63,8 @@
|
|||
<div class='author'>{{o.autor}}</div>
|
||||
<div class='float-right'>
|
||||
<form action='' onsubmit='save_scroll(this)' method='POST'>
|
||||
{% csrf_token %}
|
||||
{% csrf_token %}
|
||||
<input type='hidden' name="au" value="{{autor}}"/>
|
||||
<input type='hidden' name='pdf' value='{{pdf.id}}'>
|
||||
<input type='hidden' name='id' value='{{o.id}}'>
|
||||
<input type='hidden' name='scroll'>
|
||||
|
@ -106,7 +106,7 @@
|
|||
<img src="/static/korektury/imgs/link.png"/>
|
||||
</button></a>
|
||||
<button><a href='#op579'>
|
||||
<img title='Dal¹í oprava' src="/static/korektury/imgs/next.png"/>
|
||||
<img title='Další oprava' src="/static/korektury/imgs/next.png"/>
|
||||
</a></button>
|
||||
|
||||
</form>
|
||||
|
@ -133,7 +133,7 @@
|
|||
<img src="/static/korektury/imgs/edit.png"/></button>
|
||||
</div>
|
||||
</div>
|
||||
<div id='kt{{k.id}}'>{{k.text}}</div>
|
||||
<div id='kt{{k.id}}'>{{k.text}}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
@ -155,6 +155,12 @@
|
|||
{{ form_oprava.as_p }}
|
||||
<input type='submit' value='Odeslat'/>
|
||||
</form>
|
||||
{% if scroll %}
|
||||
<script>
|
||||
window.scrollTo(0,{{scroll}});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</body> </html>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -35,16 +35,20 @@ class KorekturyView(generic.TemplateView):
|
|||
def post(self, request, *args, **kwargs):
|
||||
form = self.form_class(request.POST)
|
||||
q = request.POST
|
||||
scroll = q.get('scroll')
|
||||
autor = q.get('au')
|
||||
if not autor:
|
||||
autor = 'anonym'
|
||||
if not scroll:
|
||||
scroll = 0
|
||||
|
||||
|
||||
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')
|
||||
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')).first()
|
||||
|
||||
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
|
||||
|
@ -82,14 +86,26 @@ class KorekturyView(generic.TemplateView):
|
|||
id = int(q.get('id'))
|
||||
kom = Komentar.objects.filter(id=id).first()
|
||||
kom.delete()
|
||||
elif (action == u'delall'):
|
||||
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf'))
|
||||
checked = q.get('yes')
|
||||
if checked:
|
||||
opravy = Oprava.objects.filter(pdf=pdf)
|
||||
komentare = Komentar.objects.filter(oprava=opravy)
|
||||
opravy.delete()
|
||||
komentare.delete()
|
||||
|
||||
|
||||
|
||||
# return HttpResponse(u'Keys: %s '%(q.iteitems()))
|
||||
return HttpResponse(u'Oprav: %d, akce: %s'%(
|
||||
len(Oprava.objects.all()),action))
|
||||
# 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())
|
||||
context = self.get_context_data()
|
||||
context['scroll'] = scroll
|
||||
context['autor'] = autor
|
||||
return render(request, 'korektury/opraf.html',context)
|
||||
# return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%(
|
||||
# len(Oprava.objects.all()),x,y,autor,text,strana))
|
||||
def get_context_data(self, **kwargs):
|
||||
|
@ -98,12 +114,24 @@ class KorekturyView(generic.TemplateView):
|
|||
context['pdf'] = pdf
|
||||
context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0]
|
||||
context['img_path'] = settings.KOREKTURY_IMG_DIR
|
||||
context['img_indexes'] = range(27)
|
||||
context['img_indexes'] = range(pdf.stran)
|
||||
context['form_oprava'] = OpravaForm()
|
||||
opravy = Oprava.objects.filter(pdf=self.kwargs['pdf'])
|
||||
zasluhy = {}
|
||||
for o in opravy:
|
||||
if o.autor in zasluhy:
|
||||
zasluhy[o.autor]+=1
|
||||
else:
|
||||
zasluhy[o.autor]=1
|
||||
o.komentare = o.komentar_set.all()
|
||||
for k in o.komentare:
|
||||
if o.autor in zasluhy:
|
||||
zasluhy[k.autor]+=1
|
||||
else:
|
||||
zasluhy[k.autor]=1
|
||||
|
||||
context['opravy'] = opravy
|
||||
context['zasluhy'] = zasluhy
|
||||
return context
|
||||
def form_valid(self,form):
|
||||
return super(KorekturyView,self).form_valid(form)
|
||||
|
|
Loading…
Reference in a new issue