def connect_signals(): case_post_save.connect(messaging_case_changed_receiver, CommCareCase, dispatch_uid='messaging_couch_case_receiver') sql_case_post_save.connect(messaging_case_changed_receiver, CommCareCaseSQL, dispatch_uid='messaging_sql_case_receiver')
def connect_signals(): if settings.SYNC_CASE_FOR_MESSAGING_ON_SAVE: case_post_save.connect(messaging_case_changed_receiver, CommCareCase, dispatch_uid='messaging_couch_case_receiver') sql_case_post_save.connect(messaging_case_changed_receiver, CommCareCaseSQL, dispatch_uid='messaging_sql_case_receiver')
def ready(self): from corehq.form_processor.models import CommCareCase from corehq.form_processor.signals import sql_case_post_save sql_case_post_save.connect( case_changed_receiver, CommCareCase, dispatch_uid="data_interfaces_sql_case_receiver")
def ready(self): from casexml.apps.case.models import CommCareCase from casexml.apps.case.signals import case_post_save from corehq.form_processor.models import CommCareCaseSQL from corehq.form_processor.signals import sql_case_post_save case_post_save.connect(case_changed_receiver, CommCareCase, dispatch_uid="data_interfaces_case_receiver") sql_case_post_save.connect(case_changed_receiver, CommCareCaseSQL, dispatch_uid="data_interfaces_sql_case_receiver")
def connect_signals(): case_post_save.connect( messaging_case_changed_receiver, CommCareCase, dispatch_uid='messaging_couch_case_receiver' ) sql_case_post_save.connect( messaging_case_changed_receiver, CommCareCaseSQL, dispatch_uid='messaging_sql_case_receiver' )
def allowed_to_forward(self, payload): return (super(SearchByParamsRepeater, self).allowed_to_forward(payload) and not payload.get_case_property('phid_for_beneficiary')) def send_request(self, repeat_record, payload): return send_request('search', payload) class ValidatePHIDRepeater(BasePHIRepeater): payload_generator_classes = (ValidatePHIDPayloadGenerator, ) friendly_name = _("Validate PHI ID") def allowed_to_forward(self, payload): return (super(ValidatePHIDRepeater, self).allowed_to_forward(payload) and payload.get_case_property('phid_for_beneficiary') and not payload.get_case_property('phid_validated')) def send_request(self, repeat_record, payload): return send_request('validate', payload) def create_phi_repeat_records(sender, case, **kwargs): create_repeat_records(SearchByParamsRepeater, case) create_repeat_records(ValidatePHIDRepeater, case) sql_case_post_save.connect(create_phi_repeat_records, CommCareCaseSQL, dispatch_uid='phi_integration_case_receiver')
from casexml.apps.case.signals import case_post_save from casexml.apps.case.models import CommCareCase from corehq.form_processor.signals import sql_case_post_save from corehq.form_processor.models import CommCareCaseSQL from dimagi.utils.logging import notify_exception def case_changed_receiver(sender, case, **kwargs): try: from corehq.apps.sms.tasks import sync_case_phone_number sync_case_phone_number.delay(case) except Exception: notify_exception(None, message="Could not create sync_case_phone_number task for case %s" % case.case_id) case_post_save.connect(case_changed_receiver, CommCareCase) sql_case_post_save.connect(case_changed_receiver, CommCareCaseSQL)
from casexml.apps.case.models import CommCareCase from casexml.apps.case.signals import case_post_save from corehq.apps.reminders.tasks import case_changed from corehq.form_processor.models import CommCareCaseSQL from corehq.form_processor.signals import sql_case_post_save from dimagi.utils.logging import notify_exception def case_changed_receiver(sender, case, **kwargs): """ Spawns a task to update reminder instances tied to the given case. """ try: case_changed.delay(case.domain, case.case_id) except Exception: notify_exception( None, message="Could not create reminders case_changed task for case %s" % case.case_id) case_post_save.connect(case_changed_receiver, CommCareCase) sql_case_post_save.connect(case_changed_receiver, CommCareCaseSQL)
def create_user_repeat_records(sender, couch_user, **kwargs): from corehq.motech.repeaters.models import UserRepeater create_repeat_records(UserRepeater, couch_user) @receiver(post_save, sender=SQLLocation, dispatch_uid="create_location_repeat_records") def create_location_repeat_records(sender, raw=False, **kwargs): from corehq.motech.repeaters.models import LocationRepeater if raw: return create_repeat_records(LocationRepeater, kwargs['instance']) @receiver(sql_case_post_save, sender=CommCareCase, dispatch_uid="fire_synchronous_repeaters") def fire_synchronous_case_repeaters(sender, case, **kwargs): """These repeaters need to fire synchronously since the changes they make to cases must reflect by the end of form submission processing """ _create_repeat_records(DataRegistryCaseUpdateRepeater, case, fire_synchronously=True) successful_form_received.connect(create_form_repeat_records) successful_form_received.connect(create_short_form_repeat_records) sql_case_post_save.connect(create_case_repeat_records, CommCareCase)