Revision 3abf6c78 snf-astakos-app/astakos/im/functions.py

b/snf-astakos-app/astakos/im/functions.py
105 105
    user.activation_sent = datetime.now()
106 106
    user.save()
107 107

  
108
def send_admin_notification(user, template_name='im/admin_notification.txt'):
108
def send_admin_notification(template_name,
109
    dictionary={},
110
    subject='alpha2 testing notification',
111
):
109 112
    """
110
    Send email to DEFAULT_ADMIN_EMAIL to notify for a new user registration.
113
    Send notification email to DEFAULT_ADMIN_EMAIL.
111 114
    
112 115
    Raises SendNotificationError
113 116
    """
114 117
    if not DEFAULT_ADMIN_EMAIL:
115 118
        return
116
    message = render_to_string(template_name, {
117
            'user': user,
118
            'baseurl': BASEURL,
119
            'site_name': SITENAME,
120
            'support': DEFAULT_CONTACT_EMAIL})
119
    message = render_to_string(template_name, dictionary)
121 120
    sender = DEFAULT_FROM_EMAIL
122 121
    try:
123
        send_mail('%s alpha2 testing account notification' % SITENAME, message, sender, [DEFAULT_ADMIN_EMAIL])
122
        send_mail(subject, message, sender, [DEFAULT_ADMIN_EMAIL])
124 123
    except (SMTPException, socket.error) as e:
125 124
        logger.exception(e)
126 125
        raise SendNotificationError()
127 126
    else:
128
        msg = 'Sent admin notification for user %s' % user.email
127
        msg = 'Sent admin notification for user %s' % dictionary
129 128
        logger._log(LOGGING_LEVEL, msg, [])
130 129

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

  
154 157
def send_invitation(invitation, template_name='im/invitation.txt'):

Also available in: Unified diff