|
|
@ -87,7 +87,7 @@ class KorekturyView(generic.TemplateView): |
|
|
|
|
|
|
|
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) |
|
|
|
op.save() |
|
|
|
self.send_email_notification_komentar(op, autor, text) |
|
|
|
self.send_email_notification_komentar(op,autor) |
|
|
|
elif (action == 'del'): |
|
|
|
id = int(q.get('id')) |
|
|
|
op = Oprava.objects.get(id=id) |
|
|
@ -125,7 +125,7 @@ class KorekturyView(generic.TemplateView): |
|
|
|
text = q.get('txt') |
|
|
|
kom = Komentar(oprava=op,autor=autor,text=text) |
|
|
|
kom.save() |
|
|
|
self.send_email_notification_komentar(op, autor, text) |
|
|
|
self.send_email_notification_komentar(op,autor) |
|
|
|
elif (action == 'update-comment'): |
|
|
|
id = int(q.get('id')) |
|
|
|
kom = Komentar.objects.get(id=id) |
|
|
@ -151,21 +151,25 @@ class KorekturyView(generic.TemplateView): |
|
|
|
context['autor'] = autor |
|
|
|
return render(request, 'korektury/opraf.html',context) |
|
|
|
|
|
|
|
def send_email_notification_komentar(self, oprava, autor, text): |
|
|
|
''' Rozesle e-mail pri pridani komentare, |
|
|
|
ktery obsahuje text komentare. |
|
|
|
def send_email_notification_komentar(self, oprava, autor): |
|
|
|
''' Rozesle e-mail pri pridani komentare / opravy, |
|
|
|
ktery obsahuje text vlakna opravy. |
|
|
|
''' |
|
|
|
|
|
|
|
# parametry e-mailu |
|
|
|
#odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk) |
|
|
|
from django.urls import reverse |
|
|
|
odkaz = self.request.build_absolute_uri(reverse('korektury', kwargs={'pdf': oprava.pdf.pk})) |
|
|
|
odkaz = f"{odkaz}#op{oprava.id}-pointer" |
|
|
|
from_email = 'korekturovatko@mam.mff.cuni.cz' |
|
|
|
subject = 'Nová korektura od {} v {}'.format(autor, |
|
|
|
oprava.pdf.nazev) |
|
|
|
subject = 'Nová korektura od {} v {}'.format(autor, oprava.pdf.nazev) |
|
|
|
texty = [(oprava.autor.osoba.plne_jmeno(),oprava.text)] |
|
|
|
for kom in Komentar.objects.filter(oprava=oprava): |
|
|
|
texty.append((kom.autor.osoba.plne_jmeno(),kom.text)) |
|
|
|
optext = "\n".join([": ".join(t) for t in texty]) |
|
|
|
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\ |
|
|
|
\nodkaz do korekturovátka: {}\n\ |
|
|
|
\nVaše korekturovátko\n".format(text, odkaz) |
|
|
|
\nVaše korekturovátko\n".format(optext, odkaz) |
|
|
|
|
|
|
|
# Prijemci e-mailu |
|
|
|
emails = set() |
|
|
@ -193,6 +197,9 @@ class KorekturyView(generic.TemplateView): |
|
|
|
|
|
|
|
if not settings.POSLI_MAILOVOU_NOTIFIKACI: |
|
|
|
print("Poslal bych upozornění na tyto adresy: ", " ".join(emails)) |
|
|
|
print("---- Upozornění:") |
|
|
|
print(text) |
|
|
|
print("---- Konec upozornění") |
|
|
|
return |
|
|
|
|
|
|
|
send_mail(subject, text, from_email, list(emails)) |
|
|
|