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