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