From 94159d6312387cd13fe6bf5b2644d3f1339cbe78 Mon Sep 17 00:00:00 2001 From: Mugisha Moses Date: Tue, 26 Jun 2012 13:05:40 +0300 Subject: [PATCH] handle birth summary --- mobilevrs_project/mobilevrs/models.py | 10 +++++----- mobilevrs_project/mobilevrs/views.py | 26 +++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/mobilevrs_project/mobilevrs/models.py b/mobilevrs_project/mobilevrs/models.py index 3b11be7..bf3a23a 100644 --- a/mobilevrs_project/mobilevrs/models.py +++ b/mobilevrs_project/mobilevrs/models.py @@ -39,9 +39,9 @@ def get_summary(session): def handle_skips(sender, **kwargs): screen = sender.last_screen() if screen and screen.slug=="birth_summary": - b_summary=Field.objects.get(slug="birth_summary") - b_summary.label=get_summary(sender) - b_summary.question=get_summary(sender) - b_summary.save() - + #b_summary=Field.objects.get(slug="birth_summary") + #b_summary.label=get_summary(sender) + #b_summary.question=get_summary(sender) + #b_summary.save() + pass ussd_pre_transition.connect(handle_skips, weak=False) diff --git a/mobilevrs_project/mobilevrs/views.py b/mobilevrs_project/mobilevrs/views.py index f46b83c..1fc0459 100644 --- a/mobilevrs_project/mobilevrs/views.py +++ b/mobilevrs_project/mobilevrs/views.py @@ -6,7 +6,8 @@ import urllib from ussd.models import * from django.conf import settings - +from .tasks import submitt_to_utl +from .models import * def advance_progress(session,input): ''' Navigate down the tree, based on the number the user has input. @@ -57,14 +58,33 @@ def ussd_menu(req, input_form=YoForm, output_template='ussd/yo.txt'): if form and form.is_valid(): session = form.cleaned_data['transactionId'] request_string = form.cleaned_data['ussdRequestString'] - response_screen = advance_progress(session,request_string) + if req.session.get('ses_str',None) and req.session['ses_str'].get('birth_summ',None): + if session.transaction_id == req.session['ses_str']['session'].transaction_id: + if request_string=="0": + response="The information was not recorded. Please start again." + else: + #submitt_to_utl.delay(session) + response="Thank you for recording a new birth! You will receive a confirmation message with the summary of the record and the registration number. " + return render_to_response(output_template, { + 'response_content':urllib.quote(str(response)), + 'action':'end', + }, context_instance=RequestContext(req)) + #import pdb;pdb.set_trace() + response_screen = advance_progress(session,request_string) action = 'end' if response_screen.is_terminal() else 'request' + if str(response_screen) == "Enter Pin to comfirm or 0 to cancel": + response_screen="Birth Summary "+get_summary(session)+str(response_screen) + ses={'session':session,'birth_summ':True} + req.session['ses_str']=ses + + + return render_to_response(output_template, { 'response_content':urllib.quote(str(response_screen)), 'action':action, }, context_instance=RequestContext(req)) - + return HttpResponse(status=404)