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
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
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
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)
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())
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)
def orgsAnnounced(self): return time.isAfter(self.orgsAnnouncedOn())
def afterOrgSignupStart(self): return self.org_app and time.isAfter(self.orgSignupStart())
def winnersAnnounced(self): return time.isAfter(self.winnersAnnouncedOn())
def tasksClaimEnded(self): return time.isAfter(self.tasksClaimEndOn())
def afterSurveyStart(self, survey): return time.isAfter(survey.survey_start)
def afterStopAllWorkDeadline(self): return time.isAfter(self.stopAllWorkDeadline())
def studentsAnnounced(self): return time.isAfter(self.studentsAnnouncedOn())
def testForNone(self): """Tests that False is returned for None.""" self.assertFalse(time.isAfter(None))
def testIsNotAfter(self): """Tests that False is returned if it is before the examined date.""" self.assertFalse(time.isAfter(timeline_utils.future()))
def testIsAfter(self): """Tests that True is returned if it is after the examined date.""" self.assertTrue(time.isAfter(timeline_utils.past()))
def afterStudentSignupStart(self): return time.isAfter(self.studentSignupStart())
def allWorkStopped(self): return time.isAfter(self.stopAllWorkOn())
def afterStudentSignupEnd(self): return time.isAfter(self.studentSignupEnd())
def allReviewsStopped(self): return time.isAfter(self.stopAllReviewsOn())
def surveyPeriod(self, survey): start = survey.survey_start end = survey.survey_end return time.isAfter(start) and time.isBefore(end)
def afterSurveyEnd(self, survey): return time.isAfter(survey.survey_end)
def tasksPubliclyVisible(self): return time.isAfter(self.tasksPubliclyVisibleOn())