Commit 83b11cd9 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

use django ADMIN & SERVER_EMAIL settings instead of DEFAULT_ADMIN_EMAIL & DEFAULT_FROM_EMAIL

parent 313e6cf9
......@@ -2,6 +2,12 @@ Changelog
---------
next
^^^^
- Setting ASTAKOS_DEFAULT_ADMIN_EMAIL has been deprecated. Use ADMINS django setting instead.
- Setting ASTAKOS_DEFAULT_FROM_EMAIL has been deprecated. Use SERVER_EMAIL django setting instead.
0.7.3
^^^^
- Rename management commands
- Optionally renew token on password change
- Preserve local password for users switched to shibboleth
......
......@@ -46,9 +46,7 @@ Name Default value
ASTAKOS_AUTH_TOKEN_DURATION one month Expiration time of newly created auth tokens
ASTAKOS_DEFAULT_USER_LEVEL 4 Default (not-invited) user level
ASTAKOS_INVITATIONS_PER_LEVEL {0:100, 1:2, 2:0, 3:0, 4:0} Number of user invitations per user level
ASTAKOS_DEFAULT_FROM_EMAIL GRNET Cloud <no-reply\@grnet.gr> ``from`` parameter passed in ``django.core.mail.send_mail``
ASTAKOS_DEFAULT_CONTACT_EMAIL support\@cloud.grnet.gr Contact email
ASTAKOS_DEFAULT_ADMIN_EMAIL support\@cloud.grnet.gr Administrator email to receive user creation notifications (if None disables notifications)
ASTAKOS_IM_MODULES ['local', 'shibboleth'] Signup modules
ASTAKOS_FORCE_PROFILE_UPDATE True Force user profile verification
ASTAKOS_INVITATIONS_ENABLED True Enable invitations
......@@ -81,6 +79,7 @@ ASTAKOS_RATELIMIT_RETRIES_ALLOWED 3
ASTAKOS_EMAILCHANGE_ENABLED False Enable email change mechanism
ASTAKOS_EMAILCHANGE_ACTIVATION_DAYS 10 Number of days that email change requests remain active
ASTAKOS_LOGGING_LEVEL INFO Message logging severity
ASTAKOS_QUOTA_HOLDER_URL '' The quota holder URI
=================================== ============================================================================= ===========================================================================================
Administrator functions
......
......@@ -45,13 +45,14 @@ from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.encoding import smart_str
from django.forms.extras.widgets import SelectDateWidget
from django.conf import settings
from astakos.im.models import (AstakosUser, EmailChange, AstakosGroup, Invitation,
Membership, GroupKind, get_latest_terms
)
from astakos.im.settings import (INVITATIONS_PER_LEVEL, DEFAULT_FROM_EMAIL,
BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY, DEFAULT_CONTACT_EMAIL,
RECAPTCHA_ENABLED, LOGGING_LEVEL
from astakos.im.settings import (INVITATIONS_PER_LEVEL, BASEURL, SITENAME,
RECAPTCHA_PRIVATE_KEY, RECAPTCHA_ENABLED, DEFAULT_CONTACT_EMAIL,
LOGGING_LEVEL
)
from astakos.im.widgets import DummyWidget, RecaptchaWidget
from astakos.im.functions import send_change_email
......@@ -401,8 +402,10 @@ class ExtendedPasswordResetForm(PasswordResetForm):
"""
for user in self.users_cache:
url = reverse('django.contrib.auth.views.password_reset_confirm',
kwargs={'uidb36':int_to_base36(user.id),
'token':token_generator.make_token(user)})
kwargs={'uidb36':int_to_base36(user.id),
'token':token_generator.make_token(user)
}
)
url = urljoin(BASEURL, url)
t = loader.get_template(email_template_name)
c = {
......@@ -413,7 +416,7 @@ class ExtendedPasswordResetForm(PasswordResetForm):
'baseurl': BASEURL,
'support': DEFAULT_CONTACT_EMAIL
}
from_email = DEFAULT_FROM_EMAIL
from_email = settings.SERVER_EMAIL
send_mail(_("Password reset on %s alpha2 testing") % SITENAME,
t.render(Context(c)), from_email, [user.email])
......
......@@ -42,6 +42,7 @@ from django.core.exceptions import ValidationError
from django.template import Context, loader
from django.contrib.auth import login as auth_login, logout as auth_logout
from django.http import HttpRequest
from django.conf import settings
from urllib import quote
from urlparse import urljoin
......@@ -49,8 +50,9 @@ from smtplib import SMTPException
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
from astakos.im.settings import (DEFAULT_CONTACT_EMAIL, SITENAME, BASEURL,
LOGGING_LEVEL
)
from astakos.im.models import AstakosUser
logger = logging.getLogger(__name__)
......@@ -90,7 +92,7 @@ def send_verification(user, template_name='im/activation_email.txt'):
'baseurl': BASEURL,
'site_name': SITENAME,
'support': DEFAULT_CONTACT_EMAIL})
sender = DEFAULT_FROM_EMAIL
sender = settings.SERVER_EMAIL
try:
send_mail('%s alpha2 testing account activation is needed' % SITENAME, message, sender, [user.email])
except (SMTPException, socket.error) as e:
......@@ -110,17 +112,17 @@ def send_admin_notification(template_name,
subject='alpha2 testing notification',
):
"""
Send notification email to DEFAULT_ADMIN_EMAIL.
Send notification email to settings.ADMINS.
Raises SendNotificationError
"""
if not DEFAULT_ADMIN_EMAIL:
if not settings.ADMINS:
return
dictionary = dictionary or {}
message = render_to_string(template_name, dictionary)
sender = DEFAULT_FROM_EMAIL
sender = settings.SERVER_EMAIL
try:
send_mail(subject, message, sender, [DEFAULT_ADMIN_EMAIL])
send_mail(subject, message, sender, [i[1] for i in settings.ADMINS])
except (SMTPException, socket.error) as e:
logger.exception(e)
raise SendNotificationError()
......@@ -140,7 +142,7 @@ def send_helpdesk_notification(user, template_name='im/account_notification.txt'
template_name,
{'user': user}
)
sender = DEFAULT_FROM_EMAIL
sender = settings.SERVER_EMAIL
try:
send_mail(
'%s alpha2 testing account activated' % SITENAME,
......@@ -169,7 +171,7 @@ def send_invitation(invitation, template_name='im/invitation.txt'):
'baseurl': BASEURL,
'site_name': SITENAME,
'support': DEFAULT_CONTACT_EMAIL})
sender = DEFAULT_FROM_EMAIL
sender = settings.SERVER_EMAIL
try:
send_mail(subject, message, sender, [invitation.username])
except (SMTPException, socket.error) as e:
......@@ -192,7 +194,7 @@ def send_greeting(user, email_template_name='im/welcome_email.txt'):
'baseurl': BASEURL,
'site_name': SITENAME,
'support': DEFAULT_CONTACT_EMAIL})
sender = DEFAULT_FROM_EMAIL
sender = settings.SERVER_EMAIL
try:
send_mail(subject, message, sender, [user.email])
except (SMTPException, socket.error) as e:
......@@ -226,7 +228,7 @@ def send_change_email(ec, request, email_template_name='registration/email_chang
url = request.build_absolute_uri(url)
t = loader.get_template(email_template_name)
c = {'url': url, 'site_name': SITENAME}
from_email = DEFAULT_FROM_EMAIL
from_email = settings.SERVER_EMAIL
send_mail(_("Email change on %s alpha2 testing") % SITENAME,
t.render(Context(c)), from_email, [ec.new_email_address])
except (SMTPException, socket.error) as e:
......
......@@ -19,9 +19,7 @@ INVITATIONS_PER_LEVEL = getattr(settings, 'ASTAKOS_INVITATIONS_PER_LEVEL', {
})
# Address to use for outgoing emails
DEFAULT_FROM_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_FROM_EMAIL', 'GRNET Cloud <no-reply@grnet.gr>')
DEFAULT_CONTACT_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_CONTACT_EMAIL', 'support@cloud.grnet.gr')
DEFAULT_ADMIN_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_ADMIN_EMAIL', 'support@cloud.grnet.gr')
# Identity Management enabled modules
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local', 'shibboleth'])
......@@ -87,7 +85,7 @@ GLOBAL_MESSAGES = getattr(settings, 'ASTAKOS_GLOBAL_MESSAGES', {})
# e.g. {'https://cms.okeanos.grnet.gr/': 'Back to ~okeanos'}
PROFILE_EXTRA_LINKS = getattr(settings, 'ASTAKOS_PROFILE_EXTRA_LINKS', {})
# The number of unsuccessful login requests per minute allowed for a specific email
# The number of unsuccessful login requests per minute allowed for a specific user
RATELIMIT_RETRIES_ALLOWED = getattr(settings, 'ASTAKOS_RATELIMIT_RETRIES_ALLOWED', 3)
# If False the email change mechanism is disabled
......@@ -100,4 +98,5 @@ EMAILCHANGE_ACTIVATION_DAYS = getattr(settings, 'ASTAKOS_EMAILCHANGE_ACTIVATION_
from logging import INFO
LOGGING_LEVEL = getattr(settings, 'ASTAKOS_LOGGING_LEVEL', INFO)
# Set the quota holder component URI
QUOTA_HOLDER_URL = getattr(settings, 'ASTAKOS_QUOTA_HOLDER_URL', '')
\ No newline at end of file
......@@ -17,9 +17,9 @@
#}
# Address to use for outgoing emails
#ASTAKOS_DEFAULT_FROM_EMAIL = 'GRNET Cloud <no-reply@grnet.gr>'
#ASTAKOS_DEFAULT_FROM_EMAIL = 'GRNET Cloud <no-reply@grnet.gr>' #Deprecated: use SERVER_EMAIL instead
#ASTAKOS_DEFAULT_CONTACT_EMAIL = 'support@cloud.grnet.gr'
#ASTAKOS_DEFAULT_ADMIN_EMAIL = 'admin@cloud.grnet.gr'
#ASTAKOS_DEFAULT_ADMIN_EMAIL = 'admin@cloud.grnet.gr' #Deprecated: use ADMINS instead
# Identity Management enabled modules
#ASTAKOS_IM_MODULES = ['local', 'twitter', 'shibboleth']
......@@ -82,3 +82,17 @@ ASTAKOS_RECAPTCHA_OPTIONS = {'theme':'clean'}
# e.g. {'https://cms.okeanos.grnet.gr/': 'Back to ~okeanos'}
#ASTAKOS_PROFILE_EXTRA_LINKS = {}
# The number of unsuccessful login requests per minute allowed for a specific user
#ASTAKOS_RATELIMIT_RETRIES_ALLOWED = 3
# If set to False the email change mechanism is disabled
#ASTAKOS_EMAILCHANGE_ENABLED = False
# Set the expiration time (in days) of email change requests
#ASTAKOS_EMAILCHANGE_ACTIVATION_DAYS = 10
# Set the astakos main functions logging severity (None to disable)
#ASTAKOS_LOGGING_LEVEL = INFO
# Set the quota holder component URI
ASTAKOS_QUOTA_HOLDER_URL = ''
\ No newline at end of file
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