2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Filter import Filter
5 from PLC.Auth import Auth
6 from PLC.Persons import Person, Persons
7 from PLC.sendmail import sendmail
9 class NotifyPersons(Method):
11 Sends an e-mail message to the specified users. If person_filter
12 is specified and is an array of user identifiers or usernames, or
13 a struct of user attributes, only users matching the filter will
16 Returns 1 if successful.
19 roles = ['admin', 'node']
23 Mixed([Mixed(Person.fields['person_id'],
24 Person.fields['email'])],
25 Filter(Person.fields)),
26 Parameter(str, "E-mail subject"),
27 Parameter(str, "E-mail body")
30 returns = Parameter(int, '1 if successful')
32 def call(self, auth, person_filter, subject, body):
33 persons = Persons(self.api, person_filter,
34 ['person_id', 'first_name', 'last_name', 'email'])
36 raise PLCInvalidArgument, "No such user(s)"
40 To = [("%s %s" % (person['first_name'], person['last_name']),
41 person['email']) for person in persons],
46 self.event_objects = {'Person': [person['person_id'] for person in persons]}
47 self.message = subject