# HG changeset patch # User Lennard de Rijk # Date 1249943832 25200 # Node ID c45dc8a5d64e8baa2336701d8cbdd35e5f785494 # Parent 6f5e303f64b5cf6508db307e0ac51aa8a1ad593a Made the specific SurveyTakeForm used in a View part of params. This fixes the Grade question not showing up on the preview and view record pages. diff -r 6f5e303f64b5 -r c45dc8a5d64e app/soc/views/models/grading_project_survey.py --- a/app/soc/views/models/grading_project_survey.py Mon Aug 10 15:28:42 2009 -0700 +++ b/app/soc/views/models/grading_project_survey.py Mon Aug 10 15:37:12 2009 -0700 @@ -71,6 +71,8 @@ new_params['name'] = "Grading Project Survey" + new_params['survey_take_form'] = GradeSurveyTakeForm + # used for sending reminders new_params['survey_type'] = 'grading' @@ -83,22 +85,6 @@ super(View, self).__init__(params=params) - def _getSurveyTakeForm(self, survey, record, params, post_dict=None): - """Returns the specific SurveyTakeForm needed for the take view. - - For args see survey.View._getSurveyTakeForm(). - - Returns: - An instance of GradeSurveyTakeForm. - """ - - survey_form = GradeSurveyTakeForm(survey_content=survey.survey_content, - survey_record=record, - survey_logic=params['logic'], - data=post_dict) - - return survey_form - def _constructFilterForProjectSelection(self, survey, params): """Returns the filter needed for the Project selection view. diff -r 6f5e303f64b5 -r c45dc8a5d64e app/soc/views/models/survey.py --- a/app/soc/views/models/survey.py Mon Aug 10 15:28:42 2009 -0700 +++ b/app/soc/views/models/survey.py Mon Aug 10 15:37:12 2009 -0700 @@ -194,6 +194,8 @@ 'clean': cleaning.validate_document_acl(self), } + new_params['survey_take_form'] = surveys.SurveyTakeForm + params = dicts.merge(params, new_params, sub_merge=True) super(View, self).__init__(params=params) @@ -217,8 +219,8 @@ # construct the form to be shown on the page # TODO(ljvderijk) Generate SurveyForm without passing along the logic - survey_form = surveys.SurveyTakeForm(survey_content=entity.survey_content, - survey_logic=self._params['logic']) + survey_form = self._params['survey_take_form']( + survey_content=entity.survey_content, survey_logic=self._params['logic']) survey_form.getFields() @@ -501,8 +503,11 @@ survey_record = self._getSurveyRecordFor(entity, request, params) # get an instance of SurveyTakeForm to use - survey_form = self._getSurveyTakeForm(entity, survey_record, params, - request.POST) + survey_form = params['survey_take_form']( + survey_content=survey.survey_content, + survey_record=record, + survey_logic=params['logic'], + data=post_dict) # fill context with the survey_form and additional information context['survey_form'] = survey_form @@ -538,25 +543,6 @@ return record_logic.getForFields(filter, unique=True) - def _getSurveyTakeForm(self, survey, record, params, post_dict=None): - """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 - post_dict: POST data to be passed to form initialization - - Returns: - An instance of SurveyTakeForm that can be used to take a Survey. - """ - - return surveys.SurveyTakeForm(survey_content=survey.survey_content, - survey_record=record, - survey_logic=params['logic'], - data=post_dict) - - def takeGet(self, request, template, context, params, survey_form, entity, record, **kwargs): """Handles the GET request for the Survey's take page. @@ -800,7 +786,7 @@ context['record'] = record_entity # store the read only survey form in the context - survey_form = surveys.SurveyTakeForm( + survey_form = params['survey_take_form']( survey_content=survey_entity.survey_content, survey_record=record_entity, survey_logic=self._params['logic'],