if len(value_list) > 1: value_list[len(value_list) - 1] = " and %s" % value_list[len(value_list) - 1] health_provider.last_reporting_date = datetime.datetime.now().date() health_provider.save() try: health_provider.facility.last_reporting_date = datetime.datetime.now().date() health_provider.facility.save() except: pass submission.response = "You reported %s.If there is an error,please resend." % ','.join(value_list) submission.save() if xform.keyword in XFORMS and \ not (submission.connection.contact and submission.connection.contact.active): submission.has_errors = True submission.save() return ## 3. -> add xforms to xformreport # append to the report if not xform.keyword in ['pow']: report_in_progress.xform_report.submissions.add(submission) report_in_progress.xform_report.save() # i may not need this submission.save() else: ## 4. -> process constraints from the DB (pow handler) constraints = { 'fhd_pow_constraint': fhd_pow_constraint} for c in XFormReport.objects.get(name='FHD').constraints: # WARNING: I'm (intentionally) not catching KeyError exceptions so all constraints must exist constraints[c](xform, submission, health_provider) xform_received.connect(fhd_xform_handler, weak=True)
except IndexError: submission.response = "Thank you. Your data on %s has been received" % xform.keyword elif xform.keyword in other_keywords: submission.response = "Thank you. Your data on %s has been received" % xform.keyword submission.save() else: submission.response = "Thank you. Your data on %s has been received" % xform.keyword submission.save() def eliminate_duplicates(sender, **kwargs): messages = kwargs["messages"] messages.exclude(connection__backend__name="yo6200").update(status="C") Poll.register_poll_type("date", "Date Response", parse_date_value, db_type=Attribute.TYPE_OBJECT) XFormField.register_field_type("emisdate", "Date", parse_date, db_type=XFormField.TYPE_INT, xforms_type="integer") XFormField.register_field_type("emisbool", "YesNo", parse_yesno, db_type=XFormField.TYPE_INT, xforms_type="integer") XFormField.register_field_type( "fuzzynum", "Fuzzy Numbers (o/0/none)", parse_fuzzy_number, db_type=XFormField.TYPE_INT, xforms_type="integer" ) script_progress_was_completed.connect(emis_autoreg, weak=False) script_progress_was_completed.connect(emis_reschedule_script, weak=False) script_progress.connect(emis_autoreg_transition, weak=False) xform_received.connect(xform_received_handler, weak=False) mass_text_sent.connect(eliminate_duplicates, weak=False)
from django.db.models.signals import post_syncdb from .utils import do_autoreg, xform_received_handler, init_structures from script.signals import script_progress_was_completed from rapidsms_xforms.models import xform_received script_progress_was_completed.connect(do_autoreg, weak=False) xform_received.connect(xform_received_handler, weak=True) post_syncdb.connect(init_structures, weak=False)