Revision 1cbce16f snf-astakos-app/astakos/im/functions.py

b/snf-astakos-app/astakos/im/functions.py
42 42
from django.template import Context, loader
43 43
from django.contrib.auth import login as auth_login, logout as auth_logout
44 44
from django.http import HttpRequest
45
from django.conf import settings
45 46

  
46 47
from urllib import quote
47 48
from urlparse import urljoin
......
49 50
from datetime import datetime
50 51
from functools import wraps
51 52

  
52
from astakos.im.settings import DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, \
53
    SITENAME, BASEURL, DEFAULT_ADMIN_EMAIL, LOGGING_LEVEL
53
from astakos.im.settings import (DEFAULT_CONTACT_EMAIL, SITENAME, BASEURL,
54
    LOGGING_LEVEL
55
)
54 56
from astakos.im.models import AstakosUser
55 57

  
56 58
logger = logging.getLogger(__name__)
......
90 92
            'baseurl': BASEURL,
91 93
            'site_name': SITENAME,
92 94
            'support': DEFAULT_CONTACT_EMAIL})
93
    sender = DEFAULT_FROM_EMAIL
95
    sender = settings.SERVER_EMAIL
94 96
    try:
95 97
        send_mail('%s alpha2 testing account activation is needed' % SITENAME, message, sender, [user.email])
96 98
    except (SMTPException, socket.error) as e:
......
110 112
    subject='alpha2 testing notification',
111 113
):
112 114
    """
113
    Send notification email to DEFAULT_ADMIN_EMAIL.
115
    Send notification email to settings.ADMINS.
114 116
    
115 117
    Raises SendNotificationError
116 118
    """
117
    if not DEFAULT_ADMIN_EMAIL:
119
    if not settings.ADMINS:
118 120
        return
119 121
    dictionary = dictionary or {}
120 122
    message = render_to_string(template_name, dictionary)
121
    sender = DEFAULT_FROM_EMAIL
123
    sender = settings.SERVER_EMAIL
122 124
    try:
123
        send_mail(subject, message, sender, [DEFAULT_ADMIN_EMAIL])
125
        send_mail(subject, message, sender, [i[1] for i in settings.ADMINS])
124 126
    except (SMTPException, socket.error) as e:
125 127
        logger.exception(e)
126 128
        raise SendNotificationError()
......
140 142
        template_name,
141 143
        {'user': user}
142 144
    )
143
    sender = DEFAULT_FROM_EMAIL
145
    sender = settings.SERVER_EMAIL
144 146
    try:
145 147
        send_mail(
146 148
            '%s alpha2 testing account activated' % SITENAME,
......
169 171
                'baseurl': BASEURL,
170 172
                'site_name': SITENAME,
171 173
                'support': DEFAULT_CONTACT_EMAIL})
172
    sender = DEFAULT_FROM_EMAIL
174
    sender = settings.SERVER_EMAIL
173 175
    try:
174 176
        send_mail(subject, message, sender, [invitation.username])
175 177
    except (SMTPException, socket.error) as e:
......
192 194
                'baseurl': BASEURL,
193 195
                'site_name': SITENAME,
194 196
                'support': DEFAULT_CONTACT_EMAIL})
195
    sender = DEFAULT_FROM_EMAIL
197
    sender = settings.SERVER_EMAIL
196 198
    try:
197 199
        send_mail(subject, message, sender, [user.email])
198 200
    except (SMTPException, socket.error) as e:
......
226 228
        url = request.build_absolute_uri(url)
227 229
        t = loader.get_template(email_template_name)
228 230
        c = {'url': url, 'site_name': SITENAME}
229
        from_email = DEFAULT_FROM_EMAIL
231
        from_email = settings.SERVER_EMAIL
230 232
        send_mail(_("Email change on %s alpha2 testing") % SITENAME,
231 233
            t.render(Context(c)), from_email, [ec.new_email_address])
232 234
    except (SMTPException, socket.error) as e:

Also available in: Unified diff