Rémi FRANÇOIS
5 years ago
15 changed files with 32 additions and 175 deletions
-
1survey_attachment/__init__.py
-
6survey_attachment/__manifest__.py
-
2survey_attachment/controllers/__init__.py
-
40survey_attachment/controllers/main.py
-
2survey_attachment/i18n/fr.po
-
2survey_attachment/models/survey_question.py
-
12survey_attachment/models/survey_user_input_line.py
-
BINsurvey_attachment/static/description/icon.png
-
BINsurvey_attachment/static/description/image_2.png
-
BINsurvey_attachment/static/description/imge_1.png
-
21survey_attachment/static/description/index.html
-
BINsurvey_attachment/static/description/survey.jpg
-
55survey_attachment/templates/page.xml
-
47survey_attachment/templates/survey_print.xml
-
19survey_attachment/templates/upload_file.xml
@ -1,2 +1 @@ |
|||
from . import controllers |
|||
from . import models |
@ -1,2 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import main |
@ -1,40 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from odoo import fields, http, SUPERUSER_ID |
|||
from odoo.http import request |
|||
from odoo.addons.survey.controllers.main import Survey |
|||
import logging |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class SurveyAttachment(Survey): |
|||
# Printing routes |
|||
@http.route(['/survey/print/<model("survey.survey"):survey>', |
|||
'/survey/print/<model("survey.survey"):survey>/<string:token>'], |
|||
type='http', auth='public', website=True) |
|||
def print_survey(self, survey, token=None, **post): |
|||
'''Display an survey in printable view; if <token> is set, it will |
|||
grab the answers of the user_input_id that has <token>.''' |
|||
|
|||
survey_question = request.env['survey.question'] |
|||
user_input = request.env['survey.user_input'] |
|||
user_input_line = request.env['survey.user_input_line'] |
|||
|
|||
question_ids = survey_question.sudo().search([('type', '=', 'upload_file'), ('survey_id', '=', survey.id)]) |
|||
user_input_id = user_input.sudo().search([('token', '=', token), ('survey_id', '=', survey.id)]) |
|||
|
|||
user_input_line_upload_file = [] |
|||
for question in question_ids: |
|||
user_input_line = user_input_line.search([ |
|||
('user_input_id', '=', user_input_id.id), |
|||
('survey_id', '=', survey.id), |
|||
('question_id', '=', question.id), |
|||
('answer_type', '=', 'upload_file') |
|||
]) |
|||
user_input_line_upload_file.append(user_input_line) |
|||
return request.render('survey.survey_print', |
|||
{'survey': survey, |
|||
'token': token, |
|||
'page_nr': 0, |
|||
'quizz_correction': True if survey.quizz_mode and token else False, |
|||
'user_input_line_upload_file': user_input_line_upload_file}) |
Before Width: 320 | Height: 320 | Size: 11 KiB |
Before Width: 1767 | Height: 868 | Size: 57 KiB |
Before Width: 1881 | Height: 903 | Size: 74 KiB |
@ -1,21 +0,0 @@ |
|||
<section class="oe_container app" style="border: 3px solid #c4d335;border-radius: 4px;box-shadow: 5px 10px 18px 6px#666666;"> |
|||
<div class="oe_row oe_spaced" style="max-width: 95%;"> |
|||
<div class="oe_span12"> |
|||
<h2 class="oe_slogan" style="font-weight: bold;">Survey Attachment </h2> |
|||
<div class="oe_demo" style="font-weight: bold; margin: 30px auto 0; padding: 0 15px 0 0; border:none; width: 96%;"> |
|||
<h3>This module allows you to upload file to survey ! </h3> |
|||
<br/> |
|||
<h3>Choose Type of question upload file</h3> |
|||
<img style="border: 2px solid #c4d335;" src="imge_1.png"/> |
|||
<br/> |
|||
<h3>Upload File here</h3> |
|||
<br/> |
|||
<img style="border: 2px solid #c4d335;" src="image_2.png"/> |
|||
<br/> |
|||
|
|||
<br/> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
</section> |
Before Width: 540 | Height: 270 | Size: 14 KiB |
@ -1,57 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<template id="survey.page" name="Page"> |
|||
<div class="page-header"> |
|||
<p class="pull-right">Page <span t-raw='page_nr + 1'/> of <span t-raw="len(survey.page_ids)"/></p> |
|||
<h1 t-field='page.title' /> |
|||
<div t-field='page.description' class="oe_no_empty"/> |
|||
</div> |
|||
|
|||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s_%s' % (survey.id, page.id)" t-att-action="'/survey/fill/%s/%s' % (slug(survey), token)" t-att-data-prefill="'/survey/prefill/%s/%s/%s' % (slug(survey), token, slug(page))" t-att-data-validate="'/survey/validate/%s' % (slug(survey))" t-att-data-submit="'/survey/submit/%s' % (slug(survey))"> |
|||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/> |
|||
<input type="hidden" name="page_id" t-att-value="page.id" /> |
|||
<input type="hidden" name="token" t-att-value="token" /> |
|||
<t t-foreach='page.question_ids' t-as='question'> |
|||
<t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" /> |
|||
<div class="js_question-wrapper" t-att-id="prefix"> |
|||
<h2> |
|||
<span t-field='question.question' /> |
|||
<span t-if="question.constr_mandatory" class="text-danger">*</span> |
|||
</h2> |
|||
<div t-field='question.description' class="text-muted oe_no_empty"/> |
|||
<t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t> |
|||
<t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t> |
|||
<t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t> |
|||
<t t-if="question.type == 'date'"><t t-call="survey.date"/></t> |
|||
<t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t> |
|||
<t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t> |
|||
<t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t> |
|||
<t t-if="question.type == 'upload_file'"><t t-call="survey_attachment.upload_file"/></t> |
|||
<div class="js_errzone alert alert-danger" style="display:none;"></div> |
|||
</div> |
|||
</t> |
|||
<div class="text-center mt16 mb16"> |
|||
<button t-if="survey.users_can_go_back and page_nr > 0" type="submit" class="btn btn-default" name="button_submit" value="previous">Previous page</button> |
|||
<button t-if="not last" type="submit" class="btn btn-primary" name="button_submit" value="next">Next page</button> |
|||
<button t-if="last" type="submit" class="btn btn-primary" name="button_submit" value="finish">Submit survey</button> |
|||
</div> |
|||
</form> |
|||
|
|||
<!-- Modal used to display error message, i.c.o. ajax error --> |
|||
<div class="modal fade" id="AJAXErrorModal" role="dialog" aria-labelledby="AJAXErrorModal" aria-hidden="true" > |
|||
<div class="modal-dialog"> |
|||
<div class="modal-content"> |
|||
<div class="modal-header"> |
|||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> |
|||
<h4 class="modal-title">A problem has occured</h4> |
|||
</div> |
|||
<div class="modal-body"><p>Something went wrong while contacting survey server. <strong class="text-danger">Your answers have probably not been recorded.</strong> Try refreshing.</p></div> |
|||
<div class="modal-footer"><button type="button" class="btn btn-primary" data-dismiss="modal">Close</button></div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<template id="page" name="Survey Attachment Page" inherit_id="survey.page"> |
|||
<xpath expr="//div[hasclass('js_question-wrapper')]/t[last()]" position='after'> |
|||
<t t-if="question.type == 'upload_file'"><t t-call="survey_attachment.upload_file"/></t> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</odoo> |
@ -1,49 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<template id="survey.survey_print" name="Survey"> |
|||
<t t-call="survey.layout"> |
|||
<div class="wrap"> |
|||
<div class="container"> |
|||
<t t-call="survey.back" /> |
|||
<div class="row"> |
|||
<div class='jumbotron mt32' style="width:100%;"> |
|||
<h1><span t-field='survey.title'/></h1> |
|||
<t t-if="survey.description"><div t-field='survey.description' class="oe_no_empty"/></t> |
|||
</div> |
|||
<div role="form" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)" style="width: -moz-available;"> |
|||
<t t-foreach="survey.page_ids" t-as="page"> |
|||
<div class="page-header"> |
|||
<h1 t-field='page.title' /> |
|||
<t t-if="page.description"><div t-field='page.description' class="oe_no_empty"/></t> |
|||
</div> |
|||
<t t-foreach='page.question_ids' t-as='question'> |
|||
<t t-set="prefix" t-value="'%s_%s_%s' % (survey.id, page.id, question.id)" /> |
|||
<div class="js_question-wrapper" t-att-id="prefix"> |
|||
<h2> |
|||
<span t-field='question.question' /> |
|||
<span t-if="question.constr_mandatory" class="text-danger">*</span> |
|||
<span t-if="quizz_correction" class="badge" t-att-data-score-question="question.id"></span> |
|||
</h2> |
|||
<t t-if="question.description"><div class="text-muted oe_no_empty" t-field='question.description'/></t> |
|||
<t t-if="question.type == 'free_text'"><t t-call="survey.free_text"/></t> |
|||
<t t-if="question.type == 'textbox'"><t t-call="survey.textbox"/></t> |
|||
<t t-if="question.type == 'numerical_box'"><t t-call="survey.numerical_box"/></t> |
|||
<t t-if="question.type == 'date'"><t t-call="survey.date"/></t> |
|||
<t t-if="question.type == 'simple_choice'"><t t-call="survey.simple_choice"/></t> |
|||
<t t-if="question.type == 'multiple_choice'"><t t-call="survey.multiple_choice"/></t> |
|||
<t t-if="question.type == 'matrix'"><t t-call="survey.matrix"/></t> |
|||
<t t-if="question.type == 'upload_file'"><t t-call="survey_attachment.upload_file"/></t> |
|||
<div class="js_errzone alert alert-danger" style="display:none;"></div> |
|||
</div> |
|||
</t> |
|||
<hr/> |
|||
</t> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</t> |
|||
<template id="survey_print" name="Survey Attachment print" inherit_id="survey.survey_print"> |
|||
<xpath expr="//div[hasclass('js_question-wrapper')]/t[last()]" position='after'> |
|||
<t t-if="question.type == 'upload_file'"><t t-call="survey_attachment.upload_file"/></t> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue