def tearDown(self): for rule in AutomaticUpdateRule.objects.filter(domain=self.domain): rule.hard_delete() for instance in run_query_across_partitioned_databases( CaseAlertScheduleInstance, Q(domain=self.domain)): delete_case_schedule_instance(instance) for instance in run_query_across_partitioned_databases( CaseTimedScheduleInstance, Q(domain=self.domain)): delete_case_schedule_instance(instance) for schedule in AlertSchedule.objects.filter(domain=self.domain): for event in schedule.memoized_events: event.content.delete() event.delete() schedule.delete() for schedule in TimedSchedule.objects.filter(domain=self.domain): for event in schedule.memoized_events: event.content.delete() event.delete() schedule.delete()
def tearDown(self): for rule in AutomaticUpdateRule.objects.filter(domain=self.domain): rule.hard_delete() for instance in paginate_query_across_partitioned_databases( CaseTimedScheduleInstance, Q(domain=self.domain)): delete_case_schedule_instance(instance) delete_timed_schedules(self.domain)
def delete_instance(instance): if isinstance(instance, AlertScheduleInstance): delete_alert_schedule_instance(instance) elif isinstance(instance, TimedScheduleInstance): delete_timed_schedule_instance(instance) elif isinstance(instance, (CaseAlertScheduleInstance, CaseTimedScheduleInstance)): delete_case_schedule_instance(instance) else: raise TypeError("Unexpected type: %s" % type(instance))
def delete_instance(instance): if isinstance(instance, AlertScheduleInstance): delete_alert_schedule_instance(instance) elif isinstance(instance, TimedScheduleInstance): delete_timed_schedule_instance(instance) elif isinstance( instance, (CaseAlertScheduleInstance, CaseTimedScheduleInstance)): delete_case_schedule_instance(instance) else: raise TypeError("Unexpected type: %s" % type(instance))
if (recipient_type, recipient_id) not in existing_instances: instance = CaseTimedScheduleInstance.create_for_recipient( schedule, recipient_type, recipient_id, start_date=start_date, move_to_next_event_not_in_the_past=True, case_id=case.case_id, rule_id=rule.pk, last_reset_case_property_value=reset_case_property_value, ) save_case_schedule_instance(instance) for key, schedule_instance in existing_instances.iteritems(): if key not in new_recipients: delete_case_schedule_instance(schedule_instance) else: if action_definition.reset_case_property_name: if reset_case_property_value != schedule_instance.last_reset_case_property_value: schedule_instance.recalculate_schedule(schedule) schedule_instance.last_reset_case_property_value = reset_case_property_value save_case_schedule_instance(schedule_instance) elif start_date and start_date != schedule_instance.start_date: schedule_instance.recalculate_schedule(schedule, new_start_date=start_date) save_case_schedule_instance(schedule_instance) @task(ignore_result=True) def deactivate_schedule_instances(schedule): pass