(self, phase_id=None, include_beginning_of_relevancy_window=True)
return valid_within_window
[current_schedule_phase = '' or ]current_schedule_phase = phase.id and
        {anchor} != '' and
        {within_form_relevancy_window} | {before_form_relevancy_expires}

        include_beginning_of_relevancy_window option either takes into account the form relevancy window
[current_schedule_phase = '' or ]current_schedule_phase = phase.id and
        {anchor} != '' and
        {within_form_relevancy_window} | {before_form_relevancy_expires}
[ current_schedule_phase = or ] current_schedule_phase = phase . id and { anchor } ! = and { within_form_relevancy_window } | { before_form_relevancy_expires }
def next_valid_schedules(self, phase_id=None, include_beginning_of_relevancy_window=True):
        """
        [current_schedule_phase = '' or ]current_schedule_phase = phase.id and
        {anchor} != '' and
        {within_form_relevancy_window} | {before_form_relevancy_expires}

        include_beginning_of_relevancy_window option either takes into account the form relevancy window
        """

        current_phase_query = XPath(self.current_schedule_phase).eq(self.phase.id)
        if phase_id == 1:
            # No visits yet
            zeroth_phase = XPath(self.current_schedule_phase).eq(XPath.string(''))
            current_phase_query = XPath.or_(zeroth_phase, current_phase_query)

        valid_within_window = XPath.and_(
            current_phase_query,
            XPath(self.anchor).neq(XPath.string('')),
            (self.within_form_relevancy() if include_beginning_of_relevancy_window
             else self.before_form_relevancy_expires()),
        )

        return valid_within_window
def next_valid_schedules ( self , phase_id = None , include_beginning_of_relevancy_window = True ) : current_phase_query = XPath ( self . current_schedule_phase ) . eq ( self . phase . id ) if phase_id == 1 : # No visits yet zeroth_phase = XPath ( self . current_schedule_phase ) . eq ( XPath . string ( '' ) ) current_phase_query = XPath . or_ ( zeroth_phase , current_phase_query ) valid_within_window = XPath . and_ ( current_phase_query , XPath ( self . anchor ) . neq ( XPath . string ( '' ) ) , ( self . within_form_relevancy ( ) if include_beginning_of_relevancy_window else self . before_form_relevancy_expires ( ) ) , ) return valid_within_window