blob: 7240be94bce2b1be590c8670a96b482cdf2f32c6 [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module containing timeline logic."""
from melange.utils import time as time_utils
def isBeforeProgramStart(timeline):
"""Tells whether the program has already started.
Args:
timeline: Timeline entity.
Returns:
True, if the program has already started. Otherwise, False.
"""
return time_utils.isBefore(timeline.program_start)
def isProgramActive(timeline):
"""Tells whether the program is currently active.
Specifically, the function returns True, if the program start date has passed
but it is still before the program end date.
Args:
timeline: Timeline entity.
Returns:
True, if the program is currently active. Otherwise, False.
"""
return time_utils.isBetween(timeline.program_start, timeline.program_end)
def isActiveStudentSignup(timeline):
"""Tells whether student sign-up period is currently active.
Args:
timeline: Timeline entity.
Returns:
True, if student sign-up period is currently active. Otherwise, False.
"""
return time_utils.isBetween(
timeline.student_signup_start, timeline.student_signup_end)
def isBeforeStudentSignup(timeline):
"""Tells whether student sign-up period has yet to start.
Args:
timeline: Timeline entity.
Returns:
True, if student sign-up period has not started. Otherwise, False.
"""
return time_utils.isBefore(timeline.student_signup_start)
def isAfterStudentSignup(timeline):
"""Tells whether student sign-up period has ended.
Args:
timeline: Timeline entity.
Returns:
True, if student sign-up period is over. Otherwise, False.
"""
return time_utils.isAfter(timeline.student_signup_end)