Skip to content

Commit

Permalink
handle birth summary
Browse files Browse the repository at this point in the history
  • Loading branch information
mossplix committed Jun 26, 2012
1 parent c0efa7f commit 94159d6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
10 changes: 5 additions & 5 deletions mobilevrs_project/mobilevrs/models.py
Expand Up @@ -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)
26 changes: 23 additions & 3 deletions mobilevrs_project/mobilevrs/views.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

0 comments on commit 94159d6

Please sign in to comment.