diff --git a/addons/survey/controllers/main.py b/addons/survey/controllers/main.py index a724e2849dd..40410755c2e 100644 --- a/addons/survey/controllers/main.py +++ b/addons/survey/controllers/main.py @@ -205,9 +205,12 @@ class WebsiteSurvey(http.Controller): answer_value = answer.value_number.__str__() elif answer.answer_type == 'date': answer_value = answer.value_date - elif answer.answer_type == 'suggestion': + elif answer.answer_type == 'suggestion' and not answer.value_suggested_row: answer_value = answer.value_suggested.id - # TODO mettre les QCM ici + elif answer.answer_type == 'suggestion' and answer.value_suggested_row: + answer_tag = "%s_%s_%s" % (answer_tag, answer.value_suggested_row.id, answer.value_suggested.id) + answer_value = answer.value_suggested.id + # TODO vérifier QCM et matrices if answer_value: ret.update({answer_tag: answer_value}) else: @@ -274,11 +277,21 @@ class WebsiteSurvey(http.Controller): return json.dumps(ret) # Printing routes - @website.route(['/survey/print//'], + @website.route(['/survey/print//', + '/survey/print///'], type='http', auth='user', multilang=True) - def print_empty_survey(self, survey=None, **post): - '''Display an empty survey in printable view''' + def print_survey(self, survey, token=None, **post): + '''Display an survey in printable view; if is set, it will + grab the answers of the user_input_id that has .''' return request.website.render('survey.survey_print', {'survey': survey, 'page_nr': 0}) + +def dict_soft_update(dictionary, key, value): + ''' Insert the pair : into the ''' + if key in dictionary: + dictionary[key].append(value) + else: + dictionary.update({key: [value]}) + # vim: exp and tab: smartindent: tabstop=4: softtabstop=4: shiftwidth=4: diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js index c43f77418b1..dc338c8a5d3 100644 --- a/addons/survey/static/src/js/survey.js +++ b/addons/survey/static/src/js/survey.js @@ -67,7 +67,7 @@ $(document).ready(function () { console.log(json_data); _.each(json_data, function(value, key){ the_form.find(".form-control[name=" + key + "]").val(value); - the_form.find("input[type='radio'][name=" + key + "]").val([value]); + the_form.find("input[name=" + key + "]").val([value]); }); }) .fail(function(){ diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 851d6fa862a..de9399d96de 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -1109,6 +1109,7 @@ class survey_user_input_line(osv.osv): ca = dict_keys_startswith(post, answer_tag) no_answers = True + # TODO gérer le cas des matrices monochoix for col in question.labels_ids: for row in question.labels_ids_2: a_tag = "%s_%s_%s" % (answer_tag, row.id, col.id) @@ -1130,12 +1131,4 @@ def dict_keys_startswith(dictionary, string): This function uses dictionary comprehensions (Python >= 2.7)''' return {k: dictionary[k] for k in filter(lambda key: key.startswith(string), dictionary.keys())} - -def dict_soft_update(dictionary, key, value): - ''' Insert the pair : into the ''' - if key in dictionary: - dictionary[key].append(value) - else: - dictionary.update({key: [value]}) - # vim: exp and tab: smartindent: tabstop=4: softtabstop=4: shiftwidth=4: