|
|
@ -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) |
|
|
|