Exemplo n.º 1
0
 def post(self):
     q_id = int(self.request.get('q_id'))
     q = QueueEntry.get_by_id(q_id)
     twilio_settings = TwilioSettings.all().get()
     schedule = SMSSchedule.all().get()
     tclient = TwilioRestClient(twilio_settings.account_sid, twilio_settings.auth_token)
     if q and q.status == 'P':
         employees = Employee.all()
         for employee in employees:
             entry = ReportingEntry.all().filter('reporting_date = ', q.report_date).filter('mobile_number =', employee.mobile_number).get()
             if not entry:
                 entry = ReportingEntry(name = employee.name, 
                            mobile_number = employee.mobile_number,
                            email = employee.email,
                            reporting_date = q.report_date,
                            reporting_location = "NOT REPORTED",
                            reporting_time = None,
                            employee = employee)
                 entry.put() 
             if schedule.status=='Active':                
                 tclient.sms.messages.create(to = employee.mobile_number, from_ = twilio_settings.twilio_number, body = schedule.message[:160])
                 smslog = SMSLog(message = schedule.message[:160],
                                 from_number = twilio_settings.twilio_number,
                                 to_number = employee.mobile_number,
                                 direction = 'outgoing-scheduled',
                                 employee_name = employee.name)
                 smslog.put()
         q.status = 'S'
         q.save()
Exemplo n.º 2
0
 def get(self):
     try:
         twilioSettings = TwilioSettings.all().get()
         result_dict = {'success':True,'twilio':twilioSettings.to_dict()}
     except:
         result_dict = {'success':False}            
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(result_dict))
Exemplo n.º 3
0
 def post(self):
     try:
         account_sid = self.request.get('account_sid')
         auth_token = self.request.get('auth_token')
         twilio_number = self.request.get('twilio_number')
         twilioSettings = TwilioSettings.all().get()
         if twilioSettings == None:
             twilioSettings = TwilioSettings(account_sid = account_sid, auth_token = auth_token,twilio_number=twilio_number)
             twilioSettings.put()
         else:
             twilioSettings.account_sid = account_sid
             twilioSettings.auth_token = auth_token
             twilioSettings.twilio_number = twilio_number
             twilioSettings.save()
         result_dict = {'success':True,'twilio':twilioSettings.to_dict()}
     except:
         result_dict = {'success':False}
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(json.dumps(result_dict))