9c4c358cca29ce7b4e2e4aef96b7015026123e32
[plcapi.git] / PLC / Methods / NotifySupport.py
1 # $Id$
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Auth import Auth
5 from PLC.sendmail import sendmail
6
7 class NotifySupport(Method):
8     """
9     Sends an e-mail message to the configured support address. 
10
11     Returns 1 if successful.
12     """
13
14     roles = ['admin']
15
16     accepts = [
17         Auth(),
18         Parameter(str, "E-mail subject"),
19         Parameter(str, "E-mail body")
20         ]
21
22     returns = Parameter(int, '1 if successful')
23
24     def call(self, auth, subject, body):
25         to_name="%s Support"%self.api.config.PLC_NAME
26         to_address=self.api.config.PLC_MAIL_SUPPORT_ADDRESS
27
28         # Send email
29         sendmail(self.api, To=(to_name,to_address),
30                  Subject = subject,
31                  Body = body)
32
33         # Logging variables
34         #self.event_objects = {'Person': [person['person_id'] for person in persons]}
35         self.message = subject
36
37         return 1