Beispiel #1
0
 def create_new_instance_for_recipient(self, recipient_type, recipient_id):
     return CaseTimedScheduleInstance.create_for_recipient(
         self.schedule,
         recipient_type,
         recipient_id,
         start_date=self.start_date,
         move_to_next_event_not_in_the_past=True,
         case_id=self.case.case_id,
         rule_id=self.rule.pk,
         last_reset_case_property_value=self.reset_case_property_value,
         schedule_revision=self.schedule_revision,
     )
Beispiel #2
0
    def create_new_instance_for_recipient(self, recipient_type, recipient_id):
        start_date = self.start_date
        if not start_date and self.model_instance:
            start_date = self.model_instance.start_date

        return CaseTimedScheduleInstance.create_for_recipient(
            self.schedule,
            recipient_type,
            recipient_id,
            start_date=start_date,
            move_to_next_event_not_in_the_past=True,
            case_id=self.case.case_id,
            rule_id=self.rule.pk,
            last_reset_case_property_value=self.reset_case_property_value,
            schedule_revision=self.schedule_revision,
        )
Beispiel #3
0
    new_recipients = set(recipients)

    # Only allow dynamic case properties here since the formatting of
    # the value is very important if we're comparing from one time to
    # the next
    reset_case_property_value = (
        case.dynamic_case_properties().get(action_definition.reset_case_property_name, '')
        if action_definition.reset_case_property_name else None
    )

    for recipient_type, recipient_id in new_recipients:
        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)