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