29 |
29 |
30 class User: |
30 class User: |
31 ''' |
31 ''' |
32 class for a xmlrpc user |
32 class for a xmlrpc user |
33 ''' |
33 ''' |
34 def __init__(self,jobqueue): |
34 def __init__(self, name, jobqueue): |
35 self.jobqueue=jobqueue |
35 self.jobqueue=jobqueue |
36 self.jobs={} |
36 self.jobs={} |
|
37 self.name=name |
37 self.features=["mail", "sms", "fax", ] |
38 self.features=["mail", "sms", "fax", ] |
38 |
39 |
39 def status(self,id=None,detailed=False): |
40 def status(self,id=None,detailed=False): |
40 ''' |
41 ''' |
41 gets the status for a job |
42 gets the status for a job |
80 ''' |
81 ''' |
81 starts the SMS with message to recipients |
82 starts the SMS with message to recipients |
82 ''' |
83 ''' |
83 if not "sms" in self.features: |
84 if not "sms" in self.features: |
84 raise NotSupportedFeature("sms") |
85 raise NotSupportedFeature("sms") |
85 id = self.jobqueue.newSMS(message,recipients,provider) |
86 id = self.jobqueue.newSMS(message,recipients,provider,user=self) |
86 self.jobs[id]=self.jobqueue[id] |
87 self.jobs[id]=self.jobqueue[id] |
87 return id |
88 return id |
88 |
89 |
89 |
90 |
90 def startFAX(self, subject, fax, recipients, provider="default"): |
91 def startFAX(self, subject, fax, recipients, provider="default"): |
92 starts the FAX with the pdf file fax and the subject |
93 starts the FAX with the pdf file fax and the subject |
93 ''' |
94 ''' |
94 logger.debug("startFAX(%s,%s,%s,%s)"%(subject, fax, recipients, provider)) |
95 logger.debug("startFAX(%s,%s,%s,%s)"%(subject, fax, recipients, provider)) |
95 if not "fax" in self.features: |
96 if not "fax" in self.features: |
96 raise NotSupportedFeature("fax") |
97 raise NotSupportedFeature("fax") |
97 id = self.jobqueue.newFAX(subject, fax,recipients,provider) |
98 |
|
99 if type(fax) != list: |
|
100 fax=[fax] |
|
101 f=[i.data for i in fax] |
|
102 |
|
103 id = self.jobqueue.newFAX(subject, f,recipients,provider,user=self) |
98 self.jobs[id]=self.jobqueue[id] |
104 self.jobs[id]=self.jobqueue[id] |
99 return id |
105 return id |
100 |
106 |
101 def startMail(self, subject, body, recipients, frm, provider="default"): |
107 def startMail(self, subject, body, recipients, frm, provider="default"): |
102 if not "mail" in self.features: |
108 if not "mail" in self.features: |
103 raise NotSupportedFeature("mail") |
109 raise NotSupportedFeature("mail") |
104 logger.debug("startMail(%s,%s,%s,%s,%s)"%(subject, body, recipients, frm, provider)) |
110 logger.debug("startMail(%s,%s,%s,%s,%s)"%(subject, body, recipients, frm, provider)) |
105 id = self.jobqueue.newMail(subject, body, recipients, frm, provider) |
111 id = self.jobqueue.newMail(subject, body, recipients, frm, provider,user=self) |
106 self.jobs[id]=self.jobqueue[id] |
112 self.jobs[id]=self.jobqueue[id] |
107 return id |
113 return id |
108 |
114 |
109 def getProvider(self, name): |
115 def getProvider(self, name): |
110 if not name in self.features: |
116 if not name in self.features: |
117 raise NotSupportedFeature(name) |
123 raise NotSupportedFeature(name) |
118 |
124 |
119 return self.jobqueue.providerlist.getDefault(name)["name"] |
125 return self.jobqueue.providerlist.getDefault(name)["name"] |
120 |
126 |
121 class Admin(User): |
127 class Admin(User): |
122 def __init__(self,jobqueue): |
128 def __init__(self, name, jobqueue): |
123 User.__init__(self, jobqueue) |
129 User.__init__(self, name, jobqueue) |
124 self.jobs=jobqueue.jobs |
130 self.jobs=jobqueue.jobs |