From 22c12473162fe01b5453acbbe15ddc8f7f30490c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Sun, 6 Nov 2016 16:39:45 +0100 Subject: [PATCH] =?UTF-8?q?Korektury:=20po=C5=A1li=20mail=20i=20autorovi?= =?UTF-8?q?=20okom.=20korektury?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- korektury/views.py | 19 +++++++++++++++---- mamweb/settings_common.py | 10 +++++++--- mamweb/settings_prod.py | 2 ++ mamweb/settings_test.py | 5 +---- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/korektury/views.py b/korektury/views.py index 5eb42bd1..70cfaf6e 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -135,21 +135,32 @@ class KorekturyView(generic.TemplateView): # Prijemci e-mailu emails = set() + # e-mail autora korektury email = oprava.autor.user.email - # nalezeni e-mailu na organizatory komentaru + if email: + emails.add(email) + + # nalezeni e-mailu na autory komentaru for komentar in oprava.komentar_set.all(): - email = komentar.autor.user.email - if email: - emails.add(email) + email_komentujiciho = komentar.autor.user.email + if email_komentujiciho: + emails.add(email_komentujiciho) + # zodpovedny org if oprava.pdf.org: email_zobpovedny = oprava.pdf.org.user.email if email_zobpovedny: emails.add(email_zobpovedny) + # odstran e-mail autora opravy + email = autor.user.email if email: emails.discard(email) + if not settings.SEND_EMAIL_NOTIFICATIONS: + print "Poslal bych upozornění na tyto adresy: ", " ".join(emails) + return + send_mail(subject, text, from_email, list(emails)) def get_context_data(self, **kwargs): diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index a1025b07..ad2b7fd7 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -242,6 +242,10 @@ LOGGING = { SEMINAR_RESENI_DIR = os.path.join('reseni') SEMINAR_KONFERY_DIR = os.path.join('konfery') -KOREKTURY_PDF_DIR = os.path.join('korektury','pdf') -KOREKTURY_IMG_DIR = os.path.join('korektury','img') -CISLO_IMG_DIR = os.path.join('cislo','img') +KOREKTURY_PDF_DIR = os.path.join('korektury', 'pdf') +KOREKTURY_IMG_DIR = os.path.join('korektury', 'img') +CISLO_IMG_DIR = os.path.join('cislo', 'img') + + +# E-MAIL NOTIFICATIONS +SEND_EMAIL_NOTIFICATIONS = False diff --git a/mamweb/settings_prod.py b/mamweb/settings_prod.py index b56a9380..8b75ce74 100644 --- a/mamweb/settings_prod.py +++ b/mamweb/settings_prod.py @@ -67,3 +67,5 @@ LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] +# E-MAIL NOTIFICATIONS +SEND_EMAIL_NOTIFICATIONS = True diff --git a/mamweb/settings_test.py b/mamweb/settings_test.py index 3d1b0010..6ffd42b8 100644 --- a/mamweb/settings_test.py +++ b/mamweb/settings_test.py @@ -10,7 +10,7 @@ import os.path # # Import common settings -from .settings_common import * +from .settings_common import LOGGING # Quick-start development settings - unsuitable for production @@ -63,6 +63,3 @@ CSRF_COOKIE_SECURE = True LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] - - -