# HG changeset patch # User Lennard de Rijk # Date 1246652862 -7200 # Node ID 53b0cc84ab0095802a4f4c8363c70b4f6f31d8fc # Parent 66405056baf872455d457615f67566d45e1486d2 Added _getSurveyTakeForm to the Survey view. Subclasses can overwrite this method to create their own form. ProjectGradingSurvey will likely be an example for this. diff -r 66405056baf8 -r 53b0cc84ab00 app/soc/views/models/survey.py --- a/app/soc/views/models/survey.py Fri Jul 03 21:59:10 2009 +0200 +++ b/app/soc/views/models/survey.py Fri Jul 03 22:27:42 2009 +0200 @@ -497,9 +497,8 @@ # try to get an existing SurveyRecord for the current user survey_record = self._getSurveyRecordFor(entity, request, params) - # create an instance of SurveyTakeForm to use - survey_form = surveys.SurveyTakeForm(survey_content=entity.survey_content, - survey_logic=self._params['logic']) + # get an instance of SurveyTakeForm to use + survey_form = self._getSurveyTakeForm(entity, survey_record, params) # fill context with the survey_form and additional information context['survey_form'] = survey_form @@ -535,6 +534,21 @@ return record_logic.getForFields(filter, unique=True) + def _getSurveyTakeForm(self, survey, record, params): + """Returns the specific SurveyTakeForm needed for the take view. + + Args: + survey: a Survey entity + record: a SurveyRecord instance if any exist + params: the params dict for the requesting View + + Returns: + An instance of SurveyTakeForm that can be used to take a Survey. + """ + + return surveys.SurveyTakeForm(survey_content=survey.survey_content, + survey_logic=params['logic']) + def takeGet(self, request, template, context, params, survey_form, entity, record, **kwargs): """Handles the GET request for the Survey's take page.