X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FMethods%2FUpdatePerson.py;h=79c1900146a58b556b69c70cea408add4d54b7ec;hb=bd0cbf4f7f2e4cf7ceda500bfa6f98c0a700018b;hp=0ddfdc4226ed9c726e187887c1f6a3cd5fa8d1b8;hpb=286cdfc25f6ef8fd3e0ed59a175bcf801b14038a;p=plcapi.git diff --git a/PLC/Methods/UpdatePerson.py b/PLC/Methods/UpdatePerson.py index 0ddfdc4..79c1900 100644 --- a/PLC/Methods/UpdatePerson.py +++ b/PLC/Methods/UpdatePerson.py @@ -1,4 +1,3 @@ -# $Id# from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed @@ -16,7 +15,7 @@ class UpdatePerson(Method): """ Updates a person. Only the fields specified in person_fields are updated, all other fields are left untouched. - + Users and techs can only update themselves. PIs can only update themselves and other non-PIs at their sites. @@ -54,38 +53,38 @@ class UpdatePerson(Method): # Check if we can update this account if not self.caller.can_update(person): raise PLCPermissionDenied, "Not allowed to update specified account" - - # Make requested associations + + # Make requested associations for field in related_fields: if field in person_fields: person.associate(auth, field, person_fields[field]) person_fields.pop(field) person.update(person_fields) - person.update_last_updated(False) + 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']]} + 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']]} # Redact password if 'password' in person_fields: person_fields['password'] = "Removed by API" self.message = 'Person %d updated: %s.' % \ (person['person_id'], person_fields.keys()) - if 'enabled' in person_fields: - self.message += ' Person enabled' + if 'enabled' in person_fields: + self.message += ' Person enabled' return 1