Exemplo n.º 1
0
def get_current_quarter(request):
    """
    Return a restclients.models.sws.Term object
    for the current quarter.
    """
    timer = Timer()
    try:
        comparison_date = get_comparison_date(request)
        term = get_term_by_date(comparison_date)
        after = get_term_after(term)

        if comparison_date > term.grade_submission_deadline.date():
            return after

        return term
    except Exception as ex:
        print ex
        log_exception(logger,
                      'get_current_term',
                      traceback.format_exc())
    finally:
        log_resp_time(logger,
                      'get_current_term',
                      timer)
    return None
Exemplo n.º 2
0
    def test_quarter_after(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
Exemplo n.º 3
0
def get_eod_specific_quarter_after(year, quarter):
    """
    Return the datetime object of the end of day on grade submission deadline
    for the term after the give year and quarter.
    Only the summer full term is relevant.
    """
    return get_term_after(
            get_specific_term(year, quarter)).get_eod_grade_submission()
Exemplo n.º 4
0
def get_bod_class_start_quarter_after(term):
    """
    Return the datetime object of the beginning of the first instruction
    day in the term after the give year and quarter.
    Only the summer full term is relevant.
    """
    nterm = get_term_after(term)
    if nterm is None:
        return None
    return nterm.get_bod_first_day()
Exemplo n.º 5
0
def get_next_quarter(request):
    """
    Returna restclients.models.sws.Term object
    for the current quarter refered in the user session.
    """
    if hasattr(request, 'myuw_next_quarter'):
        return request.myuw_next_quarter
    term = get_term_after(get_current_quarter(request))
    request.myuw_next_quarter = term
    return term
Exemplo n.º 6
0
    def test_terms_after(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next_autumn = get_next_autumn_term(starting)
            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            self.assertEquals(next_autumn, next1)
            next_non_summer_term = get_next_non_summer_term(get_current_term())
            self.assertEquals(next_autumn, next_non_summer_term)

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
Exemplo n.º 7
0
    def test_terms_after(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next_autumn = get_next_autumn_term(starting)
            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            self.assertEquals(next_autumn, next1)
            next_non_summer_term = get_next_non_summer_term(get_current_term())
            self.assertEquals(next_autumn, next_non_summer_term)

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
Exemplo n.º 8
0
def get_next_quarter(request):
    """
    Returna restclients.models.sws.Term object
    for the next quarter.
    """
    timer = Timer()
    try:
        current = get_current_quarter(request)
        return get_term_after(current)
    except Exception as ex:
        log_exception(logger,
                      'get_next_term',
                      traceback.format_exc())
    finally:
        log_resp_time(logger,
                      'get_next_term',
                      timer)
    return None
Exemplo n.º 9
0
    def get_terms_with_active_channels(self, channel_type):
        """
        Returns a list of all sws.Terms that have active channels.
        """
        # Check the current term, and the next 3, to see if they have
        # a channel for any course in that term.
        # when the sws term resource provides us with a timeschedule publish
        # date, use that instead of this.
        term = get_current_term()
        terms = []
        if self.term_has_active_channel(channel_type, term):
            terms.append(term)

        for i in range(3):
            term = get_term_after(term)
            if self.term_has_active_channel(channel_type, term):
                terms.append(term)

        return terms
Exemplo n.º 10
0
def get_current_quarter(request):
    """
    Return a restclients.models.sws.Term object
    for the current quarter refered in the user session.
    """
    timer = Timer()
    if hasattr(request, 'myuw_current_quarter'):
        return request.myuw_current_quarter

    try:
        comparison_date = get_comparison_date(request)
        term = get_term_by_date(comparison_date)
        after = get_term_after(term)

        if comparison_date > term.grade_submission_deadline.date():
            request.myuw_current_quarter = after
            return after

        request.myuw_current_quarter = term
        return term
    finally:
        log_resp_time(logger,
                      'get_current_term',
                      timer)
Exemplo n.º 11
0
def get_all_active_terms(dt):
    curr_term = get_current_active_term(dt)
    next_term = get_term_after(curr_term)
    return [curr_term, next_term, get_term_after(next_term)]
Exemplo n.º 12
0
def get_current_active_term(dt):
    curr_term = get_term_by_date(dt.date())
    if dt > curr_term.grade_submission_deadline:
        curr_term = get_term_after(curr_term)
    return curr_term