From 5aaa2760a98cfdf39e395d1d31b0ccda345c05ba Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Thu, 2 Jul 2020 11:07:45 +0200 Subject: [PATCH 01/23] =?UTF-8?q?Rozes=C3=ADl=C3=A1n=C3=AD=20zve=C5=99ejn?= =?UTF-8?q?=C4=9Bn=C3=A9ho=20=C4=8D=C3=ADsla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/views.py | 2 +- mamweb/settings_common.py | 2 +- mamweb/settings_prod.py | 2 +- seminar/models.py | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/korektury/views.py b/korektury/views.py index c3f22569..bca5b66a 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -162,7 +162,7 @@ class KorekturyView(generic.TemplateView): if email: emails.discard(email) - if not settings.SEND_EMAIL_NOTIFICATIONS: + if not settings.POSLI_MAILOVOU_NOTIFIKACI: print("Poslal bych upozornění na tyto adresy: ", " ".join(emails)) return diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 62cd7fe7..510b35f3 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -279,4 +279,4 @@ CISLO_IMG_DIR = os.path.join('cislo', 'img') # E-MAIL NOTIFICATIONS -SEND_EMAIL_NOTIFICATIONS = False +POSLI_MAILOVOU_NOTIFIKACI = False diff --git a/mamweb/settings_prod.py b/mamweb/settings_prod.py index 1c223842..0374d88b 100644 --- a/mamweb/settings_prod.py +++ b/mamweb/settings_prod.py @@ -66,4 +66,4 @@ LOGGING['handlers']['registration_error_log']['filename'] = '/home/mam-web/logs/ # E-MAIL NOTIFICATIONS -SEND_EMAIL_NOTIFICATIONS = True +POSLI_MAILOVOU_NOTIFIKACI = True diff --git a/seminar/models.py b/seminar/models.py index deb0c9b9..f148ca64 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -32,6 +32,8 @@ from seminar.treelib import safe_pred from polymorphic.models import PolymorphicModel +from django.core.mail import EmailMessage +from seminar.utils import aktivniResitele class SeminarModelBase(models.Model): @@ -539,9 +541,43 @@ class Cislo(SeminarModelBase): return None return c + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.__original_verejne = self.verejne_db + + def posli_cislo_mailem(self): + # parametry e-mailu + odkaz = self.get_absolute_url() + + poslat_z_mailu = 'zadani@mam.mff.cuni.cz' + predmet = 'Vyšlo číslo {}'.format(self.kod()) + text_mailu = 'Ahoj,\n' \ + 'na adrese {} najdete nejnovější číslo.\n' \ + 'Vaše M&M\n'.format(odkaz) + + # Prijemci e-mailu + emaily = map(lambda r: r.osoba.email, aktivniResitele(self )) + + if not settings.POSLI_MAILOVOU_NOTIFIKACI: + print("Poslal bych upozornění na tyto adresy: ", " ".join(emaily)) + return + + email = EmailMessage( + subject=predmet, + body=text_mailu, + from_email=poslat_z_mailu, + bcc=list(emaily) + #bcc = příjemci skryté kopie + ) + + email.send() + def save(self, *args, **kwargs): super().save(*args, **kwargs) self.vygeneruj_nahled() + # Při zveřejnění pošle mail + if self.verejne_db and not self.__original_verejne: + self.posli_cislo_mailem() # *Node.save() aktualizuje název *Nodu. try: self.cislonode.save() From 7e588098d166697bd4d7e0d5d41b916db5a53c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C?= Date: Tue, 12 Jan 2021 22:29:38 +0100 Subject: [PATCH 02/23] =?UTF-8?q?p=C5=99id=C3=A1n=20odkaz=20na=20vytvo?= =?UTF-8?q?=C5=99en=C3=AD=20sous=20na=20rozcestn=C3=ADk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/orgorozcestnik.html | 1 + 1 file changed, 1 insertion(+) diff --git a/seminar/templates/seminar/orgorozcestnik.html b/seminar/templates/seminar/orgorozcestnik.html index 73268812..5f89d36d 100644 --- a/seminar/templates/seminar/orgorozcestnik.html +++ b/seminar/templates/seminar/orgorozcestnik.html @@ -58,6 +58,7 @@

Soustředění