Exemplo n.º 1
0
 def set_plan(self, plan_name):
     self.site.plan = Plan.objects.get(name=plan_name)
     self.site.save()
     sender = Sender(self.site, 'test')
     sender.get_sms_response = Mock(return_value={})
     sender.record_sms = Mock(return_value={})
     self.sender = sender
Exemplo n.º 2
0
 def set_plan(self, plan_name):
     self.site.plan = Plan.objects.get(name=plan_name)
     self.site.save()
     sender = Sender(self.site, 'test')
     sender.get_sms_response = Mock(return_value={})
     sender.record_sms = Mock(return_value={})
     self.sender = sender
Exemplo n.º 3
0
 def clean(self):
     data = self.cleaned_data
     count = self.cleaned_data.get('count')
     if not count:
         return data
     sender = Sender(self.site, data.get('body', ''))
     try:
         sender.add_recipients(*['dummy' for n in range(count)])
     except CapExceeded, e:
         if e.cap_type == 'soft':
             self.cap_exceeded = True
         else:
             raise forms.ValidationError('The send count requested will exceed your monthly plan limit.')
Exemplo n.º 4
0
 def clean(self):
     data = self.cleaned_data
     count = self.cleaned_data.get('count')
     if not count:
         return data
     sender = Sender(self.site, data.get('body', ''))
     try:
         sender.add_recipients(*['dummy' for n in range(count)])
     except CapExceeded, e:
         if e.cap_type == 'soft':
             self.cap_exceeded = True
         else:
             raise forms.ValidationError(
                 'The send count requested will exceed your monthly plan limit.'
             )
Exemplo n.º 5
0
 def broadcast(self):
     sender = Sender(self.settings.site_set.all()[0],
                     self.body,
                     campaign=self)
     sender.add_recipients(*list(self.subscribers.all()))
     sender.send_message()
     self.completed = True
     self.save()
Exemplo n.º 6
0
def send_single_sms(request, phone_number):
    if request.method == 'POST':
        try:
            subscriber = request.site.sms.smssubscriber_set.get(phone_number=phone_number)
        except SmsSubscriber.DoesNotExist:
            subscriber = None
        if subscriber is not None and not subscriber.is_active:
            raise Http404
        sender = Sender(request.site, request.POST['text'])
        sender.add_recipients(subscriber or phone_number)
        sender.send_message()
        messages.success(request, "SMS sent successfully.")
        return HttpResponseRedirect(request.META['HTTP_REFERER'])
    else:
        return direct_to_template(request, template='dashboard/marketing/includes/single_sms_form.html', extra_context={
            'subscriber_id': phone_number
        })
Exemplo n.º 7
0
 def get_mock_sender(self):
     sender = Sender(self.site, self.settings.intro_sms)
     sender.get_sms_response = Mock(return_value={})
     return sender
Exemplo n.º 8
0
 def sender(self, site, body):
     return Sender(site, body)
Exemplo n.º 9
0
 def broadcast(self):
     sender = Sender(self.settings.site_set.all()[0], self.body, campaign=self)
     sender.add_recipients(*list(self.subscribers.all()))
     sender.send_message()
     self.completed = True
     self.save()
Exemplo n.º 10
0
 def get_mock_sender(self):
     sender = Sender(self.site, self.settings.intro_sms) 
     sender.get_sms_response = Mock(return_value={})
     return sender