# HG changeset patch # User Lennard de Rijk # Date 1246204438 -7200 # Node ID 05c430d1c1475812bb21924b03c18158109e3b43 # Parent 7fac0da44bbf17ca90cac98c2bd2c4387aa3cd75 Renamed opening to survey_start and deadline to survey_end. Symmetry seems to be both pleasing and helpful when understanding the code. diff -r 7fac0da44bbf -r 05c430d1c147 app/soc/models/survey.py --- a/app/soc/models/survey.py Sun Jun 28 17:44:44 2009 +0200 +++ b/app/soc/models/survey.py Sun Jun 28 17:53:58 2009 +0200 @@ -142,14 +142,14 @@ ' in the sidebar menu.') #: Date at which the survey becomes available for taking. - opening = db.DateTimeProperty(required=False) - opening.help_text = ugettext( + survey_start = db.DateTimeProperty(required=False) + survey_start.help_text = ugettext( 'Indicates a date before which this survey' ' cannot be taken or displayed.') #: Deadline for taking survey. - deadline = db.DateTimeProperty(required=False) - deadline.help_text = ugettext( + survey_end = db.DateTimeProperty(required=False) + survey_end.help_text = ugettext( 'Indicates a date after which this survey' ' cannot be taken.') diff -r 7fac0da44bbf -r 05c430d1c147 app/soc/views/models/survey.py --- a/app/soc/views/models/survey.py Sun Jun 28 17:44:44 2009 +0200 +++ b/app/soc/views/models/survey.py Sun Jun 28 17:53:58 2009 +0200 @@ -306,7 +306,7 @@ return True def getStatus(self, request, context, user, survey): - """Determine if we're past deadline or before opening, check user rights. + """Determine if the survey is available for taking, check user rights. """ read_only = (context.get("read_only", False) or @@ -315,8 +315,8 @@ ) now = datetime.datetime.now() - # check deadline, see check for opening below - if survey.deadline and now > survey.deadline: + # check survey end date, see check for start below + if survey.survey_end and now > survey.survey_end: # are we already passed the deadline? context["notice"] = "The Deadline For This Survey Has Passed" read_only = True @@ -330,11 +330,11 @@ not_ready = False - # check if we're past the opening date - if survey.opening and now < survey.opening: + # check if we're past the start date + if survey.survey_start and now < survey.survey_start: not_ready = True - # only users that can edit a survey should see it before opening + # only users that can edit a survey should see it before it can be taken if not can_write: context["notice"] = "There is no such survey available." return False @@ -349,11 +349,11 @@ """ if not read_only: - if not survey.deadline: + if not survey.survey_end: deadline_text = "" else: deadline_text = " by " + str( - survey.deadline.strftime("%A, %d. %B %Y %I:%M%p")) + survey.survey_end.strftime("%A, %d. %B %Y %I:%M%p")) if survey_record: help_text = "Edit and re-submit this survey" + deadline_text + "." @@ -637,14 +637,14 @@ context.update(local) params['edit_form'] = HelperForm(params['edit_form']) - if entity.deadline and datetime.datetime.now() > entity.deadline: - # are we already passed the deadline? + if entity.survey_end and datetime.datetime.now() > entity.survey_end: + # are we already passed the survey end date? context["passed_deadline"] = True return super(View, self).editGet(request, entity, context, params=params) def getMenusForScope(self, entity, params): - """List featured surveys iff after the opening date and before deadline. + """List featured surveys iff after they are availble to be taken. """ # only list surveys for registered users @@ -689,11 +689,11 @@ elif not survey_rights[entity.read_access]: continue - # omit if either before opening or after deadline - if entity.opening and entity.opening > now: + # omit if either before start or after end + if entity.survey_start and entity.survey_start > now: continue - if entity.deadline and entity.deadline < now: + if entity.survey_end and entity.survey_end < now: continue #TODO only if a document is readable it might be added