Browse Source

Korektury: pošli mail i autorovi okom. korektury

remotes/origin/posli-mail-autorovi-korektury
Matěj Kocián 8 years ago
parent
commit
d34f75e455
  1. 17
      korektury/views.py
  2. 4
      mamweb/settings_common.py
  3. 2
      mamweb/settings_prod.py
  4. 5
      mamweb/settings_test.py

17
korektury/views.py

@ -135,21 +135,32 @@ class KorekturyView(generic.TemplateView):
# Prijemci e-mailu # Prijemci e-mailu
emails = set() emails = set()
# e-mail autora korektury
email = oprava.autor.user.email email = oprava.autor.user.email
# nalezeni e-mailu na organizatory komentaru
for komentar in oprava.komentar_set.all():
email = komentar.autor.user.email
if email: if email:
emails.add(email) emails.add(email)
# nalezeni e-mailu na autory komentaru
for komentar in oprava.komentar_set.all():
email_komentujiciho = komentar.autor.user.email
if email_komentujiciho:
emails.add(email_komentujiciho)
# zodpovedny org # zodpovedny org
if oprava.pdf.org: if oprava.pdf.org:
email_zobpovedny = oprava.pdf.org.user.email email_zobpovedny = oprava.pdf.org.user.email
if email_zobpovedny: if email_zobpovedny:
emails.add(email_zobpovedny) emails.add(email_zobpovedny)
# odstran e-mail autora opravy # odstran e-mail autora opravy
email = autor.user.email
if email: if email:
emails.discard(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)) send_mail(subject, text, from_email, list(emails))
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):

4
mamweb/settings_common.py

@ -245,3 +245,7 @@ SEMINAR_KONFERY_DIR = os.path.join('konfery')
KOREKTURY_PDF_DIR = os.path.join('korektury', 'pdf') KOREKTURY_PDF_DIR = os.path.join('korektury', 'pdf')
KOREKTURY_IMG_DIR = os.path.join('korektury', 'img') KOREKTURY_IMG_DIR = os.path.join('korektury', 'img')
CISLO_IMG_DIR = os.path.join('cislo', 'img') CISLO_IMG_DIR = os.path.join('cislo', 'img')
# E-MAIL NOTIFICATIONS
SEND_EMAIL_NOTIFICATIONS = False

2
mamweb/settings_prod.py

@ -67,3 +67,5 @@ LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins']
LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins']
# E-MAIL NOTIFICATIONS
SEND_EMAIL_NOTIFICATIONS = True

5
mamweb/settings_test.py

@ -10,7 +10,7 @@ import os.path
# #
# Import common settings # Import common settings
from .settings_common import * from .settings_common import * # zatim nutne, casem snad vyresime # noqa
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
@ -63,6 +63,3 @@ CSRF_COOKIE_SECURE = True
LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['']['handlers'] = ['console', 'mail_admins']
LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins'] LOGGING['loggers']['django']['handlers'] = ['console', 'mail_admins']

Loading…
Cancel
Save