def ajax_POST_test(self, get, post): form = MessageForm(post) if form.is_valid(): contact = form.cleaned_data["contact"] message = form.cleaned_data["message"] phone = form.cleaned_data["phone"] backend = Backend.objects.get(name="clickatell") connection, _ = Connection.objects.get_or_create(contact=contact, identity=phone, backend=backend) message = OutgoingMessage(connection, message) return message.send()
def ajax_POST_test(self, get, post): form = MessageForm(post) if form.is_valid(): contact = form.cleaned_data['contact'] message = form.cleaned_data['message'] phone = form.cleaned_data['phone'] backend = Backend.objects.get(name='clickatell') connection, _ = Connection.objects.get_or_create(contact=contact, identity=phone, backend=backend) message = OutgoingMessage(connection, message) return message.send()
def test(request): if request.POST: form = MessageForm(request.POST) if form.is_valid(): post = { 'contact': form.cleaned_data['contact'].id, 'message': form.cleaned_data['message'], 'phone': form.cleaned_data['phone'], } status, _, _ = ajax_request('rclickatell/test', post=post) if status == 200: logging.info('Successfully sent message to rclickatell backend') else: logging.error('Failed to send test Clickatell message') else: form = MessageForm() context = {'form': form} return render_to_response('rclickatell/message.html', context, context_instance=RequestContext(request))
def test(request): if request.POST: form = MessageForm(request.POST) if form.is_valid(): post = { 'contact': form.cleaned_data['contact'].id, 'message': form.cleaned_data['message'], 'phone': form.cleaned_data['phone'], } status, _, _ = ajax_request('rclickatell/test', post=post) if status == 200: logging.info( 'Successfully sent message to rclickatell backend') else: logging.error('Failed to send test Clickatell message') else: form = MessageForm() context = {'form': form} return render_to_response('rclickatell/message.html', context, context_instance=RequestContext(request))