From 128fc0eb4eabe385e258b5002695b27dad6bf7ef Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 5 Jan 2007 18:03:39 +0000 Subject: [PATCH] - added Person.send_initiate_password_reset_email method --- PLC/Persons.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/PLC/Persons.py b/PLC/Persons.py index efff5c9d..8b4b631d 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Persons.py,v 1.25 2007/01/05 15:54:39 tmack Exp $ +# $Id: Persons.py,v 1.26 2007/01/05 15:56:16 tmack Exp $ # from types import StringTypes @@ -20,6 +20,7 @@ from PLC.Parameter import Parameter from PLC.Filter import Filter from PLC.Table import Row, Table from PLC.Keys import Key, Keys +from PLC.Messages import Message, Messages import PLC.Sites class Person(Row): @@ -289,6 +290,28 @@ class Person(Row): self['site_ids'].remove(site_id) self['site_ids'].insert(0, site_id) + def send_initiate_password_reset_email(self): + # email user next step instructions + to_addr = {} + to_addr[self['email']] = "%s %s" % \ + (self['first_name'], self['last_name']) + from_addr = {} + from_addr[self.api.config.PLC_MAIL_SUPPORT_ADDRESS] = \ + "%s %s" % ('Planetlab', 'Support') + messages = Messages(self.api, ['PASSWORD_RESET_INITIATE']) + if not messages: + raise PLCAPIError, "Email template not found" + message = messages[0] + subject = message['subject'] + template = message['template'] % \ + (self.api.config.PLC_WWW_HOST, + self['verification_key'], self['person_id'], + self.api.config.PLC_MAIL_SUPPORT_ADDRESS, + self.api.config.PLC_WWW_HOST) + + self.api.mailer.mail(to_addr, None, from_addr, subject, template) + + def delete(self, commit = True): """ Delete existing account. -- 2.47.0