Merge branch 'test' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into test
This commit is contained in:
commit
a308543a2b
2 changed files with 29 additions and 0 deletions
|
@ -69,3 +69,9 @@ LOGGING['handlers']['registration_logfile']['filename'] = '/home/mam-web/logs/te
|
|||
LOGGING['handlers']['registration_error_log']['filename'] = '/home/mam-web/logs/test/registration_errors.log'
|
||||
|
||||
FILE_UPLOAD_PERMISSIONS = 0o440
|
||||
|
||||
# Testování e-mailů
|
||||
POSLI_MAILOVOU_NOTIFIKACI = True
|
||||
EMAIL_BACKEND = 'various.mail_prefixer.PrefixingMailBackend'
|
||||
# TODO Pouze na otestování testu… Zvolit konferu!
|
||||
TESTOVACI_EMAILOVA_KONFERENCE = ['jonas.havelka@volny.cz']
|
||||
|
|
23
various/mail_prefixer.py
Normal file
23
various/mail_prefixer.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
"""A simple email backend, which only prepends all subjects with a string.
|
||||
|
||||
Used to distinguish testing emails from production ones."""
|
||||
|
||||
# We try to monkeypatch django.core.mail.backends.smtp :-)
|
||||
|
||||
from django.core.mail.backends.smtp import EmailBackend as DjangoSMTPBackend
|
||||
from django.conf import settings
|
||||
|
||||
class PrefixingMailBackend(DjangoSMTPBackend):
|
||||
# method _send is not probably meant to be monkey_patched, so we patch send_messages instead.
|
||||
def send_messages(self, messages):
|
||||
prefix = '[Mail z testwebu]'
|
||||
for message in messages:
|
||||
# We hope that this is a django.core.mail.message.EmailMessage
|
||||
|
||||
if message.from_email != settings.SERVER_EMAIL:
|
||||
message.subject = prefix + ' ' + message.subject
|
||||
message.body = "Bylo by posláno na e-maily: " + str(message.recipients()) + "\n\n" + message.body
|
||||
message.to = settings.TESTOVACI_EMAILOVA_KONFERENCE
|
||||
message.cc = []
|
||||
message.bcc = []
|
||||
return super().send_messages(messages)
|
Loading…
Reference in a new issue