Revision 23b9b72f snf-astakos-app/astakos/im/functions.py
b/snf-astakos-app/astakos/im/functions.py | ||
---|---|---|
232 | 232 |
msg = 'Sent change email for %s' % ec.user.email |
233 | 233 |
logger._log(LOGGING_LEVEL, msg, []) |
234 | 234 |
|
235 |
def activate(user, email_template_name='im/welcome_email.txt'): |
|
235 |
def activate(user, email_template_name='im/welcome_email.txt', |
|
236 |
helpdesk_email_template_name='im/helpdesk_notification.txt', verify_email=False): |
|
236 | 237 |
""" |
237 | 238 |
Activates the specific user and sends email. |
238 | 239 |
|
239 | 240 |
Raises SendGreetingError, ValidationError |
240 | 241 |
""" |
241 | 242 |
user.is_active = True |
243 |
if verify_email: |
|
244 |
user.email_verified = True |
|
242 | 245 |
user.save() |
246 |
send_helpdesk_notification(user, helpdesk_email_template_name) |
|
243 | 247 |
send_greeting(user, email_template_name) |
244 | 248 |
|
249 |
def switch_account_to_shibboleth(user, local_user): |
|
250 |
if not user or not isinstance(user, AstakosUser): |
|
251 |
return |
|
252 |
|
|
253 |
if not local_user or not isinstance(user, AstakosUser): |
|
254 |
return |
|
255 |
|
|
256 |
if not user.provider == 'shibboleth': |
|
257 |
return |
|
258 |
|
|
259 |
user.delete() |
|
260 |
local_user.provider = 'shibboleth' |
|
261 |
local_user.set_unusable_password() |
|
262 |
local_user.third_party_identifier = user.third_party_identifier |
|
263 |
local_user.save() |
|
264 |
return local_user |
|
265 |
|
|
245 | 266 |
def invite(invitation, inviter, email_template_name='im/welcome_email.txt'): |
246 | 267 |
""" |
247 | 268 |
Send an invitation email and upon success reduces inviter's invitation by one. |
Also available in: Unified diff