From e6727422d9d25fd980f27126ca51c0280a3aca43 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 10 Oct 2008 18:15:55 +0000 Subject: [PATCH] send users an email when their account is enabled/disables --- PLC/Methods/UpdatePerson.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PLC/Methods/UpdatePerson.py b/PLC/Methods/UpdatePerson.py index 8f74fc04..20436049 100644 --- a/PLC/Methods/UpdatePerson.py +++ b/PLC/Methods/UpdatePerson.py @@ -3,6 +3,7 @@ from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Persons import Person, Persons from PLC.Auth import Auth +from PLC.sendmail import sendmail related_fields = Person.related_fields.keys() can_update = lambda (field, value): field in \ @@ -62,7 +63,19 @@ class UpdatePerson(Method): person.update(person_fields) person.update_last_updated(False) person.sync() - + + if 'enabled' in person_fields: + To = [("%s %s" % (person['first_name'], person['last_name']), person['email'])] + Cc = [] + if person['enabled']: + Subject = "%s account enabled" % (self.api.config.PLC_NAME) + Body = "Your %s account has been enabled. Please visit %s to access your account." % (self.api.config.PLC_NAME, self.api.config.PLC_WWW_HOST) + else: + Subject = "%s account disabled" % (self.api.config.PLC_NAME) + Body = "Your %s account has been disabled. Please contact your PI or PlanetLab support for more information" % (self.api.config.PLC_NAME) + sendmail(self.api, To = To, Cc = Cc, Subject = Subject, Body = Body) + + # Logging variables self.event_objects = {'Person': [person['person_id']]} -- 2.47.0