Revision a0be6a0c snf-astakos-app/astakos/im/functions.py

b/snf-astakos-app/astakos/im/functions.py
128 128
        msg = 'Sent admin notification for user %s' % user.email
129 129
        logger._log(LOGGING_LEVEL, msg, [])
130 130

  
131
def send_helpdesk_notification(user, template_name='im/helpdesk_notification.txt'):
132
    """
133
    Send email to DEFAULT_CONTACT_EMAIL to notify for a new user activation.
134
    
135
    Raises SendNotificationError
136
    """
137
    if not DEFAULT_CONTACT_EMAIL:
138
        return
139
    message = render_to_string(template_name, {
140
            'user': user,
141
            'baseurl': BASEURL,
142
            'site_name': SITENAME,
143
            'support': DEFAULT_ADMIN_EMAIL})
144
    sender = DEFAULT_FROM_EMAIL
145
    try:
146
        send_mail('%s alpha2 testing account notification' % SITENAME, message, sender, [DEFAULT_CONTACT_EMAIL])
147
    except (SMTPException, socket.error) as e:
148
        logger.exception(e)
149
        raise SendNotificationError()
150
    else:
151
        msg = 'Sent helpdesk admin notification for user %s' % user.email
152
        logger._log(LOGGING_LEVEL, msg, [])
153

  
131 154
def send_invitation(invitation, template_name='im/invitation.txt'):
132 155
    """
133 156
    Send invitation email.
......
273 296
    def __init__(self):
274 297
        self.message = _('Failed to send change email')
275 298
        super(ChangeEmailError, self).__init__()
299

  
300
class SendNotificationError(SendMailError):
301
    def __init__(self):
302
        self.message = _('Failed to send notification email')
303
        super(SendNotificationError, self).__init__()

Also available in: Unified diff