|
|
@ -56,6 +56,11 @@ class KorekturyView(generic.TemplateView): |
|
|
|
template_name = 'korektury/opraf.html' |
|
|
|
form_class = OpravaForm |
|
|
|
|
|
|
|
def setup(self, request, *args, **kwargs): |
|
|
|
super().setup(request, *args, **kwargs) |
|
|
|
self.pdf_id = self.kwargs["pdf"] |
|
|
|
self.pdf = get_object_or_404(KorekturovanePDF, id=self.pdf_id) |
|
|
|
|
|
|
|
def post(self, request, *args, **kwargs): |
|
|
|
form = self.form_class(request.POST) |
|
|
|
q = request.POST |
|
|
@ -77,9 +82,8 @@ class KorekturyView(generic.TemplateView): |
|
|
|
y = int(q.get('y')) |
|
|
|
text = q.get('txt') |
|
|
|
strana = int(q.get('img-id')[4:]) |
|
|
|
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=self.pdf) |
|
|
|
op.save() |
|
|
|
self.send_email_notification_komentar(op,autor) |
|
|
|
elif (action == 'del'): |
|
|
@ -132,9 +136,8 @@ class KorekturyView(generic.TemplateView): |
|
|
|
kom = Komentar.objects.get(id=id) |
|
|
|
kom.delete() |
|
|
|
elif (action == 'set-state'): |
|
|
|
pdf = KorekturovanePDF.objects.get(id=q.get('pdf')) |
|
|
|
pdf.status = q.get('state') # FIXME odchytávat blbosti? |
|
|
|
pdf.save() |
|
|
|
self.pdf.status = q.get('state') # FIXME odchytávat blbosti? |
|
|
|
self.pdf.save() |
|
|
|
context = self.get_context_data() |
|
|
|
context['scroll'] = scroll |
|
|
|
context['autor'] = autor |
|
|
@ -193,13 +196,12 @@ class KorekturyView(generic.TemplateView): |
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
pdf = get_object_or_404(KorekturovanePDF, id=self.kwargs['pdf']) |
|
|
|
context['pdf'] = pdf |
|
|
|
context['img_prefix'] = pdf.get_prefix() |
|
|
|
context['pdf'] = self.pdf |
|
|
|
context['img_prefix'] = self.pdf.get_prefix() |
|
|
|
context['img_path'] = settings.KOREKTURY_IMG_DIR |
|
|
|
context['img_indexes'] = range(pdf.stran) |
|
|
|
context['img_indexes'] = range(self.pdf.stran) |
|
|
|
context['form_oprava'] = OpravaForm() |
|
|
|
opravy = Oprava.objects.filter(pdf=self.kwargs['pdf']) |
|
|
|
opravy = Oprava.objects.filter(pdf=self.pdf_id) |
|
|
|
zasluhy = {} |
|
|
|
for o in opravy: |
|
|
|
if o.autor in zasluhy: |
|
|
|