示例#1
0
def canProposalBeResubmitted(proposal, profile, program, timeline):
  """Tells whether the specified proposal can be resubmitted by the specified
  student for the given program.

  Args:
    proposal: Proposal entity.
    profile: Profile entity.
    program: Program entity.
    timeline: Timeline entity for the program.

  Returns:
    True, if the proposal can be resubmitted; False otherwise
  """
  # check if given timeline corresponds to the given program
  if not timeline_logic.isTimelineForProgram(timeline.key(), program.key()):
    raise ValueError('The specified timeline (key_name: %s) is '
        'not related to program (key_name: %s).' % (
            timeline.key().name(), program.key().name()))

  if time_utils.isAfter(timeline.accepted_students_announced_deadline):
    # students have been accepted / rejected
    return False
  elif proposal.status != proposal_model.STATUS_WITHDRAWN:
    # only withdrawn proposals can be resubmitted
    return False
  elif profile.student_data.number_of_proposals >= program.apps_tasks_limit:
    # student has not reached the limit of proposals per program
    return False
  else:
    return True
示例#2
0
def canProposalBeResubmitted(proposal, profile, program, timeline):
    """Tells whether the specified proposal can be resubmitted by the specified
  student for the given program.

  Args:
    proposal: Proposal entity.
    profile: Profile entity.
    program: Program entity.
    timeline: Timeline entity for the program.

  Returns:
    True, if the proposal can be resubmitted; False otherwise
  """
    # check if given timeline corresponds to the given program
    if not timeline_logic.isTimelineForProgram(timeline.key(), program.key()):
        raise ValueError('The specified timeline (key_name: %s) is '
                         'not related to program (key_name: %s).' %
                         (timeline.key().name(), program.key().name()))

    if time_utils.isAfter(timeline.accepted_students_announced_deadline):
        # students have been accepted / rejected
        return False
    elif proposal.status != proposal_model.STATUS_WITHDRAWN:
        # only withdrawn proposals can be resubmitted
        return False
    elif profile.student_data.number_of_proposals >= program.apps_tasks_limit:
        # student has not reached the limit of proposals per program
        return False
    else:
        return True
示例#3
0
    def state(self):
        """Returns state of the period with respect to the current moment in time.

    For the period bounded at both start and end,there are
    three possibilities. The current moment may be:
    - before the period
    - in the period
    - after the period

    For a period with no start date defined, the current moment may be:
    - in the period
    - after the period

    For period with no end date defined, the current moment may be:
    - before the period
    - in the period

    Returns:
      A constant representing the current state of the period. Can be one of
      PRE_PERIOD_STATE, IN_PERIOD_STATE or POST_PERIOD_STATE.
    """
        # unbounded period
        if not self.start and not self.end:
            return IN_PERIOD_STATE

        # period right-unbounded
        elif self.start and not self.end:
            if time.isBefore(self.start):
                return PRE_PERIOD_STATE
            else:
                return IN_PERIOD_STATE

        # period left-unbounded
        elif not self.start and self.end:
            if time.isAfter(self.end):
                return POST_PERIOD_STATE
            else:
                return IN_PERIOD_STATE

        # period bounded
        elif time.isBefore(self.start):
            return PRE_PERIOD_STATE
        elif time.isAfter(self.end):
            return POST_PERIOD_STATE
        else:
            return IN_PERIOD_STATE
示例#4
0
  def afterProgramStart(self):
    """Returns a bool indicating whether the program start date has passed
    or not.

    Returns:
      True if the current date is after program start date; False otherwise
    """
    return time.isAfter(self.timeline.program_start)
示例#5
0
  def state(self):
    """Returns state of the period with respect to the current moment in time.

    For the period bounded at both start and end,there are
    three possibilities. The current moment may be:
    - before the period
    - in the period
    - after the period

    For a period with no start date defined, the current moment may be:
    - in the period
    - after the period

    For period with no end date defined, the current moment may be:
    - before the period
    - in the period

    Returns:
      A constant representing the current state of the period. Can be one of
      PRE_PERIOD_STATE, IN_PERIOD_STATE or POST_PERIOD_STATE.
    """
    # unbounded period
    if not self.start and not self.end:
      return IN_PERIOD_STATE

    # period right-unbounded
    elif self.start and not self.end:
      if time.isBefore(self.start):
        return PRE_PERIOD_STATE
      else:
        return IN_PERIOD_STATE

    # period left-unbounded
    elif not self.start and self.end:
      if time.isAfter(self.end):
        return POST_PERIOD_STATE
      else:
        return IN_PERIOD_STATE

    # period bounded
    elif time.isBefore(self.start):
      return PRE_PERIOD_STATE
    elif time.isAfter(self.end):
      return POST_PERIOD_STATE
    else:
      return IN_PERIOD_STATE
示例#6
0
  def afterFormSubmissionStart(self):
    """Answers the question if the current point in time is after students can
    start submitting their forms.

    Returns:
      A bool value which is True if the current time is after students can
        start submitting their forms.
    """
    return time.isAfter(self.formSubmissionStartOn())
示例#7
0
    def afterFormSubmissionStart(self):
        """Answers the question if the current point in time is after students can
    start submitting their forms.

    Returns:
      A bool value which is True if the current time is after students can
        start submitting their forms.
    """
        return time.isAfter(self.formSubmissionStartOn())
示例#8
0
  def afterFirstSurveyStart(self, surveys):
    """Returns True if we are past at least one survey has start date.

    Args:
      surveys: List of survey entities for which we need to determine if
        at least one of them have started
    """
    first_survey_start = min([s.survey_start for s in surveys])
    return time.isAfter(first_survey_start)
示例#9
0
    def afterFirstSurveyStart(self, surveys):
        """Returns True if we are past at least one survey has start date.

    Args:
      surveys: List of survey entities for which we need to determine if
        at least one of them have started
    """
        first_survey_start = min([s.survey_start for s in surveys])
        return time.isAfter(first_survey_start)
示例#10
0
 def orgsAnnounced(self):
   return time.isAfter(self.orgsAnnouncedOn())
示例#11
0
 def afterOrgSignupStart(self):
   return self.org_app and time.isAfter(self.orgSignupStart())
示例#12
0
 def winnersAnnounced(self):
     return time.isAfter(self.winnersAnnouncedOn())
示例#13
0
 def tasksClaimEnded(self):
     return time.isAfter(self.tasksClaimEndOn())
示例#14
0
 def afterSurveyStart(self, survey):
   return time.isAfter(survey.survey_start)
示例#15
0
 def afterStopAllWorkDeadline(self):
   return time.isAfter(self.stopAllWorkDeadline())
示例#16
0
 def tasksClaimEnded(self):
   return time.isAfter(self.tasksClaimEndOn())
示例#17
0
 def studentsAnnounced(self):
     return time.isAfter(self.studentsAnnouncedOn())
示例#18
0
 def testForNone(self):
   """Tests that False is returned for None."""
   self.assertFalse(time.isAfter(None))
示例#19
0
 def testIsNotAfter(self):
   """Tests that False is returned if it is before the examined date."""
   self.assertFalse(time.isAfter(timeline_utils.future()))
示例#20
0
 def testIsAfter(self):
   """Tests that True is returned if it is after the examined date."""
   self.assertTrue(time.isAfter(timeline_utils.past()))
示例#21
0
 def afterStudentSignupStart(self):
   return time.isAfter(self.studentSignupStart())
示例#22
0
 def allWorkStopped(self):
   return time.isAfter(self.stopAllWorkOn())
示例#23
0
 def afterStudentSignupEnd(self):
   return time.isAfter(self.studentSignupEnd())
示例#24
0
 def allReviewsStopped(self):
     return time.isAfter(self.stopAllReviewsOn())
示例#25
0
 def surveyPeriod(self, survey):
   start = survey.survey_start
   end = survey.survey_end
   return time.isAfter(start) and time.isBefore(end)
示例#26
0
 def winnersAnnounced(self):
   return time.isAfter(self.winnersAnnouncedOn())
示例#27
0
 def afterSurveyEnd(self, survey):
   return time.isAfter(survey.survey_end)
示例#28
0
 def tasksPubliclyVisible(self):
   return time.isAfter(self.tasksPubliclyVisibleOn())
示例#29
0
 def studentsAnnounced(self):
   return time.isAfter(self.studentsAnnouncedOn())
示例#30
0
 def allWorkStopped(self):
     return time.isAfter(self.stopAllWorkOn())
示例#31
0
 def allReviewsStopped(self):
   return time.isAfter(self.stopAllReviewsOn())
示例#32
0
 def tasksPubliclyVisible(self):
     return time.isAfter(self.tasksPubliclyVisibleOn())