(self, schedule_form, custom_event_forms)
return True
We can't automatically sort the events on day and time because the
        time for some events is pulled from a case property at reminder run time.
        So we just raise an error when the events are out of order and
        let the user order them appropriately.
We can't automatically sort the events on day and time because the
        time for some events is pulled from a case property at reminder run time.
        So we just raise an error when the events are out of order and
        let the user order them appropriately.
We can t automatically sort the events on day and time because the time for some events is pulled from a case property at reminder run time . So we just raise an error when the events are out of order and let the user order them appropriately .
def validate_timed_schedule_order(self, schedule_form, custom_event_forms):
        """
        We can't automatically sort the events on day and time because the
        time for some events is pulled from a case property at reminder run time.
        So we just raise an error when the events are out of order and
        let the user order them appropriately.
        """
        send_time_type = schedule_form.cleaned_data['send_time_type']
        prev_form = None
        for form in custom_event_forms:
            if prev_form:
                if send_time_type in (TimedSchedule.EVENT_SPECIFIC_TIME, TimedSchedule.EVENT_RANDOM_TIME):
                    if(
                        (form.cleaned_data['day'], form.cleaned_data['time']) <
                        (prev_form.cleaned_data['day'], prev_form.cleaned_data['time'])
                    ):
                        form.add_error(
                            'time',
                            ValidationError(
                                _("The day and time for this event are out of order. "
                                  "Please move this event into the correct order.")
                            )
                        )
                        # We have to return False and not check the rest because it will try to check
                        # the 'time' field of prev_form which has been removed from cleaned_data now
                        return False
                elif send_time_type == TimedSchedule.EVENT_CASE_PROPERTY_TIME:
                    if form.cleaned_data['day'] < prev_form.cleaned_data['day']:
                        form.add_error(
                            'day',
                            ValidationError(
                                _("The day for this event is out of order. "
                                  "Please move this event into the correct order.")
                            )
                        )
                        # We have to return False and not check the rest because it will try to check
                        # the 'day' field of prev_form which has been removed from cleaned_data now
                        return False
                else:
                    raise ValueError("Unexpected value for send_time_type: '%s'" % send_time_type)

            prev_form = form

        return True
def validate_timed_schedule_order ( self , schedule_form , custom_event_forms ) : send_time_type = schedule_form . cleaned_data [ 'send_time_type' ] prev_form = None for form in custom_event_forms : if prev_form : if send_time_type in ( TimedSchedule . EVENT_SPECIFIC_TIME , TimedSchedule . EVENT_RANDOM_TIME ) : if ( ( form . cleaned_data [ 'day' ] , form . cleaned_data [ 'time' ] ) < ( prev_form . cleaned_data [ 'day' ] , prev_form . cleaned_data [ 'time' ] ) ) : form . add_error ( 'time' , ValidationError ( _ ( "The day and time for this event are out of order. " "Please move this event into the correct order." ) ) ) # We have to return False and not check the rest because it will try to check # the 'time' field of prev_form which has been removed from cleaned_data now return False elif send_time_type == TimedSchedule . EVENT_CASE_PROPERTY_TIME : if form . cleaned_data [ 'day' ] < prev_form . cleaned_data [ 'day' ] : form . add_error ( 'day' , ValidationError ( _ ( "The day for this event is out of order. " "Please move this event into the correct order." ) ) ) # We have to return False and not check the rest because it will try to check # the 'day' field of prev_form which has been removed from cleaned_data now return False else : raise ValueError ( "Unexpected value for send_time_type: '%s'" % send_time_type ) prev_form = form return True