Ejemplo n.º 1
0
def request_call(request):
    if request.POST:
        form = RequestCallForm(request.POST)
        if form.is_valid():
            clinic = form.cleaned_data['clinic']
            # normalize
            msisdn = normalize_msisdn(form.cleaned_data['msisdn'])
            # orm object
            msisdn_record, _ = MSISDN.objects.get_or_create(msisdn=msisdn)
            pcm = PleaseCallMe(user=clinic.user, clinic=clinic, 
                msisdn=msisdn_record, timestamp=datetime.now(), 
                message='Please call me!', notes='Call request issued via txtAlert Bookings')
            pcm.save()
            messages.add_message(request, messages.INFO, 
                        'Your call request has been registered. '\
                        'The clinic will call you back as soon as possible.')
            return HttpResponseRedirect(reverse('bookings:request_call'))
    else:
        form = RequestCallForm(initial={
            'msisdn': '' if request.user.is_anonymous() else request.user.username
        })
    
    if request.user.is_anonymous():
        profile = patient = None
    else:
        profile = request.user.get_profile()
        patient = profile.patient
    
    return render_to_response('request_call.html', {
        'profile': profile,
        'patient': patient,
        'form': form,
    }, context_instance=RequestContext(request))
Ejemplo n.º 2
0
 def create(self, request):
     msisdn = normalize_msisdn(request.POST.get('msisdn'))
     msisdn_record, _ = MSISDN.objects.get_or_create(msisdn=msisdn)
     pcm = CorePleaseCallMe(user=request.user, msisdn=msisdn_record,
             timestamp=datetime.now(), message='Please call me!',
             notes='Call request issued via txtAlert Bookings USSD')
     pcm.save()
     return pcm
Ejemplo n.º 3
0
 def create(self, request):
     msisdn = normalize_msisdn(request.POST.get('msisdn'))
     msisdn_record, _ = MSISDN.objects.get_or_create(msisdn=msisdn)
     pcm = CorePleaseCallMe(
         user=request.user,
         msisdn=msisdn_record,
         timestamp=datetime.now(),
         message='Please call me!',
         notes='Call request issued via txtAlert Bookings USSD')
     pcm.save()
     return pcm
Ejemplo n.º 4
0
def request_call(request):
    if request.POST:
        form = RequestCallForm(request.POST)
        if form.is_valid():
            clinic = form.cleaned_data['clinic']
            # normalize
            msisdn = normalize_msisdn(form.cleaned_data['msisdn'])
            # orm object
            msisdn_record, _ = MSISDN.objects.get_or_create(msisdn=msisdn)
            pcm = PleaseCallMe(
                user=clinic.user,
                clinic=clinic,
                msisdn=msisdn_record,
                timestamp=datetime.now(),
                message='Please call me!',
                notes='Call request issued via txtAlert Bookings')
            pcm.save()
            messages.add_message(request, messages.INFO,
                        'Your call request has been registered. '\
                        'The clinic will call you back as soon as possible.')
            return HttpResponseRedirect(reverse('bookings:request_call'))
    else:
        form = RequestCallForm(initial={
            'msisdn':
            '' if request.user.is_anonymous() else request.user.username
        })

    if request.user.is_anonymous():
        profile = patient = None
    else:
        profile = request.user.get_profile()
        patient = profile.patient

    return render_to_response('request_call.html', {
        'profile': profile,
        'patient': patient,
        'form': form,
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 5
0
def request_call(request):
    if request.POST:
        form = RequestCallForm(request.POST)
        if form.is_valid():
            clinic = form.cleaned_data["clinic"]
            # normalize
            msisdn = normalize_msisdn(form.cleaned_data["msisdn"])
            # orm object
            msisdn_record, _ = MSISDN.objects.get_or_create(msisdn=msisdn)
            pcm = PleaseCallMe(
                user=clinic.user,
                clinic=clinic,
                msisdn=msisdn_record,
                timestamp=datetime.now(),
                message="Called request via txtAlert Bookings",
            )
            pcm.save()
            messages.add_message(
                request,
                messages.INFO,
                "Your call request has been registered. " "The clinic will call you back as soon as possible.",
            )
            return HttpResponseRedirect(reverse("bookings:request_call"))
    else:
        form = RequestCallForm(initial={"msisdn": "" if request.user.is_anonymous() else request.user.username})

    if request.user.is_anonymous():
        profile = patient = None
    else:
        profile = request.user.get_profile()
        patient = profile.patient

    return render_to_response(
        "request_call.html",
        {"profile": profile, "patient": patient, "form": form},
        context_instance=RequestContext(request),
    )