Commit 83999d61 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou

Configurable subjects for all emails send by astakos

parent 03edc91a
......@@ -3,11 +3,20 @@ Changelog
v0.7.4
^^^^^^
- Use https for google webfonts
- Configurable subjects for all emails send by astakos app. Introduced settings
* ASTAKOS_INVITATION_EMAIL_SUBJECT
* ASTAKOS_GREETING_EMAIL_SUBJECT
* ASTAKOS_FEEDBACK_EMAIL_SUBJECT
* ASTAKOS_VERIFICATION_EMAIL_SUBJECT
* ASTAKOS_ADMIN_NOTIFICATION_EMAIL_SUBJECT
* ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT
* ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT
* ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT
v0.7.3
^^^^^^
- Use https for google webfonts
- Fix anonymoususer logout
v0.7.1
......
......@@ -50,7 +50,7 @@ from django.utils.encoding import smart_str
from astakos.im.models import AstakosUser, Invitation, get_latest_terms, EmailChange
from astakos.im.settings import INVITATIONS_PER_LEVEL, DEFAULT_FROM_EMAIL, \
BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY, DEFAULT_CONTACT_EMAIL, \
RECAPTCHA_ENABLED, LOGGING_LEVEL
RECAPTCHA_ENABLED, LOGGING_LEVEL, PASSWORD_RESET_EMAIL_SUBJECT
from astakos.im.widgets import DummyWidget, RecaptchaWidget
from astakos.im.functions import send_change_email
......@@ -413,7 +413,7 @@ class ExtendedPasswordResetForm(PasswordResetForm):
'support': DEFAULT_CONTACT_EMAIL
}
from_email = DEFAULT_FROM_EMAIL
send_mail(_("Password reset on %s alpha2 testing") % SITENAME,
send_mail(_(PASSWORD_RESET_EMAIL_SUBJECT),
t.render(Context(c)), from_email, [user.email])
class EmailChangeForm(forms.ModelForm):
......
......@@ -50,7 +50,10 @@ from datetime import datetime
from functools import wraps
from astakos.im.settings import DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, \
SITENAME, BASEURL, DEFAULT_ADMIN_EMAIL, LOGGING_LEVEL
SITENAME, BASEURL, DEFAULT_ADMIN_EMAIL, LOGGING_LEVEL, \
VERIFICATION_EMAIL_SUBJECT, ADMIN_NOTIFICATION_EMAIL_SUBJECT, \
HELPDESK_NOTIFICATION_EMAIL_SUBJECT, INVITATION_EMAIL_SUBJECT, \
GREETING_EMAIL_SUBJECT, FEEDBACK_EMAIL_SUBJECT, EMAIL_CHANGE_EMAIL_SUBJECT
from astakos.im.models import Invitation, AstakosUser
logger = logging.getLogger(__name__)
......@@ -92,7 +95,7 @@ def send_verification(user, template_name='im/activation_email.txt'):
'support': DEFAULT_CONTACT_EMAIL})
sender = DEFAULT_FROM_EMAIL
try:
send_mail('%s alpha2 testing account activation is needed' % SITENAME, message, sender, [user.email])
send_mail(_(VERIFICATION_EMAIL_SUBJECT), message, sender, [user.email])
except (SMTPException, socket.error) as e:
logger.exception(e)
raise SendVerificationError()
......@@ -120,7 +123,7 @@ def send_admin_notification(user, template_name='im/admin_notification.txt'):
'support': DEFAULT_CONTACT_EMAIL})
sender = DEFAULT_FROM_EMAIL
try:
send_mail('%s alpha2 testing account notification' % SITENAME, message, sender, [DEFAULT_ADMIN_EMAIL])
send_mail(_(ADMIN_NOTIFICATION_EMAIL_SUBJECT), message, sender, [DEFAULT_ADMIN_EMAIL])
except (SMTPException, socket.error) as e:
logger.exception(e)
raise SendNotificationError()
......@@ -143,7 +146,7 @@ def send_helpdesk_notification(user, template_name='im/helpdesk_notification.txt
'support': DEFAULT_ADMIN_EMAIL})
sender = DEFAULT_FROM_EMAIL
try:
send_mail('%s alpha2 testing account notification' % SITENAME, message, sender, [DEFAULT_CONTACT_EMAIL])
send_mail(_(HELPDESK_NOTIFICATION_EMAIL_SUBJECT), message, sender, [DEFAULT_CONTACT_EMAIL])
except (SMTPException, socket.error) as e:
logger.exception(e)
raise SendNotificationError()
......@@ -157,7 +160,7 @@ def send_invitation(invitation, template_name='im/invitation.txt'):
Raises SendInvitationError
"""
subject = _('Invitation to %s alpha2 testing' % SITENAME)
subject = _(INVITATION_EMAIL_SUBJECT)
url = '%s?code=%d' % (urljoin(BASEURL, reverse('astakos.im.views.index')), invitation.code)
message = render_to_string('im/invitation.txt', {
'invitation': invitation,
......@@ -181,7 +184,7 @@ def send_greeting(user, email_template_name='im/welcome_email.txt'):
Raises SMTPException, socket.error
"""
subject = _('Welcome to %s alpha2 testing' % SITENAME)
subject = _(GREETING_EMAIL_SUBJECT)
message = render_to_string(email_template_name, {
'user': user,
'url': urljoin(BASEURL, reverse('astakos.im.views.index')),
......@@ -199,7 +202,7 @@ def send_greeting(user, email_template_name='im/welcome_email.txt'):
logger._log(LOGGING_LEVEL, msg, [])
def send_feedback(msg, data, user, email_template_name='im/feedback_mail.txt'):
subject = _("Feedback from %s alpha2 testing" % SITENAME)
subject = _(FEEDBACK_EMAIL_SUBJECT)
from_email = user.email
recipient_list = [DEFAULT_CONTACT_EMAIL]
content = render_to_string(email_template_name, {
......@@ -223,7 +226,7 @@ def send_change_email(ec, request, email_template_name='registration/email_chang
t = loader.get_template(email_template_name)
c = {'url': url, 'site_name': SITENAME}
from_email = DEFAULT_FROM_EMAIL
send_mail(_("Email change on %s alpha2 testing") % SITENAME,
send_mail(_(EMAIL_CHANGE_EMAIL_SUBJECT),
t.render(Context(c)), from_email, [ec.new_email_address])
except (SMTPException, socket.error) as e:
logger.exception(e)
......
......@@ -99,3 +99,22 @@ EMAILCHANGE_ACTIVATION_DAYS = getattr(settings, 'ASTAKOS_EMAILCHANGE_ACTIVATION_
# Set the astakos main functions logging severity (None to disable)
from logging import INFO
LOGGING_LEVEL = getattr(settings, 'ASTAKOS_LOGGING_LEVEL', INFO)
# Configurable email subjects
INVITATION_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_INVITATION_EMAIL_SUBJECT',
'Invitation to %s alpha2 testing' % SITENAME)
GREETING_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_GREETING_EMAIL_SUBJECT',
'Welcome to %s alpha2 testing' % SITENAME)
FEEDBACK_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_FEEDBACK_EMAIL_SUBJECT',
'Feedback from %s alpha2 testing' % SITENAME)
VERIFICATION_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_VERIFICATION_EMAIL_SUBJECT',
'%s alpha2 testing account activation is needed' % SITENAME)
ADMIN_NOTIFICATION_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_ADMIN_NOTIFICATION_EMAIL_SUBJECT',
'%s alpha2 testing account notification' % SITENAME)
HELPDESK_NOTIFICATION_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT',
'%s alpha2 testing account notification' % SITENAME)
EMAIL_CHANGE_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT',
'Email change on %s alpha2 testing' % SITENAME)
PASSWORD_RESET_EMAIL_SUBJECT = getattr(settings, 'ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT',
'Password reset on %s alpha2 testing' % SITENAME)
......@@ -99,3 +99,12 @@
# Set the astakos main functions logging severity (None to disable)
#from logging import INFO
#ASTAKOS_LOGGING_LEVEL = INFO
#ASTAKOS_INVITATION_EMAIL_SUBJECT = 'Invitation to %s alpha2 testing' % SITENAME
#ASTAKOS_GREETING_EMAIL_SUBJECT = 'Welcome to %s alpha2 testing' % SITENAME
#ASTAKOS_FEEDBACK_EMAIL_SUBJECT = 'Feedback from %s alpha2 testing' % SITENAME
#ASTAKOS_VERIFICATION_EMAIL_SUBJECT = '%s alpha2 testing account activation is needed' % SITENAME
#ASTAKOS_ADMIN_NOTIFICATION_EMAIL_SUBJECT = '%s alpha2 testing account notification' % SITENAME
#ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT = '%s alpha2 testing account notification' % SITENAME
#ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT = 'Email change on %s alpha2 testing' % SITENAME
#ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT = 'Password reset on %s alpha2 testing' % SITENAME
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment