[FIX] Fixing things & views with comment answers
bzr revid: rim@openerp.com-20140409085216-5knre0uoxygunazr
This commit is contained in:
parent
beeb188ae8
commit
e7766719fe
|
@ -46,18 +46,12 @@ class WebsiteSurvey(http.Controller):
|
|||
|
||||
# In case of auth required, block public user
|
||||
if survey.auth_required and uid == request.registry['website'].get_public_user(cr, uid, context):
|
||||
return request.website.render("website.401")
|
||||
return request.website.render("website.403")
|
||||
|
||||
# In case of non open surveys
|
||||
if survey.state != 'open':
|
||||
if survey.stage_id.closed:
|
||||
return request.website.render("survey.notopen")
|
||||
|
||||
# If enough surveys completed
|
||||
if survey.user_input_limit > 0:
|
||||
completed = user_input_obj.search(cr, uid, [('state', '=', 'done')], count=True)
|
||||
if completed >= survey.user_input_limit:
|
||||
return request.website.render("survey.notopen")
|
||||
|
||||
# Everything seems to be ok
|
||||
return None
|
||||
|
||||
|
@ -100,11 +94,8 @@ class WebsiteSurvey(http.Controller):
|
|||
|
||||
# Manual surveying
|
||||
if not token:
|
||||
if survey.visible_to_user:
|
||||
user_input_id = user_input_obj.create(cr, uid, {'survey_id': survey.id}, context=context)
|
||||
user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
|
||||
else: # An user cannot open hidden surveys without token
|
||||
return request.website.render("website.403")
|
||||
user_input_id = user_input_obj.create(cr, uid, {'survey_id': survey.id}, context=context)
|
||||
user_input = user_input_obj.browse(cr, uid, [user_input_id], context=context)[0]
|
||||
else:
|
||||
try:
|
||||
user_input_id = user_input_obj.search(cr, uid, [('token', '=', token)], context=context)[0]
|
||||
|
|
|
@ -5,6 +5,7 @@ access_survey_question_public,survey.question public,model_survey_question,base.
|
|||
access_survey_label_public,survey.label public,model_survey_label,base.group_public,1,0,0,0
|
||||
access_survey_user_input_public,survey.user_input public,model_survey_user_input,base.group_public,1,1,1,0
|
||||
access_survey_user_input_line_public,survey.user_input_line public,model_survey_user_input_line,base.group_public,1,1,1,0
|
||||
access_survey_stage_public,survey.stage public,model_survey_stage,base.group_public,1,0,0,0
|
||||
access_survey_user,survey.survey user,model_survey_survey,base.group_survey_user,1,0,0,0
|
||||
access_survey_page_user,survey.page user,model_survey_page,base.group_survey_user,1,0,0,0
|
||||
access_survey_question_user,survey.question user,model_survey_question,base.group_survey_user,1,0,0,0
|
||||
|
|
|
|
@ -28,7 +28,7 @@
|
|||
<record id="survey_rule" model="ir.rule">
|
||||
<field name="name">Access to survey for regular users</field>
|
||||
<field name="model_id" ref="survey.model_survey_survey"/>
|
||||
<field name="domain_force">[('state', '=', 'open'), ('visible_to_user', '=', True)]</field>
|
||||
<field name="domain_force">[('stage_id.closed', '=', False)]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_survey_user'))]"/>
|
||||
<field eval="0" name="perm_unlink"/>
|
||||
<field eval="0" name="perm_write"/>
|
||||
|
|
|
@ -176,8 +176,6 @@ class survey_survey(osv.Model):
|
|||
}
|
||||
|
||||
_defaults = {
|
||||
'auth_required': True,
|
||||
'users_can_go_back': False,
|
||||
'color': 0
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<span t-field='question.question' />
|
||||
<span t-if="question.constr_mandatory" class="text-danger">*</span>
|
||||
</h2>
|
||||
<p class="text-muted"><t t-if="question.description"><span t-field='question.description'/></t></p>
|
||||
<div t-field='question.description' class="text-muted"/>
|
||||
<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>
|
||||
|
@ -165,16 +165,16 @@
|
|||
<option t-att-value='label.id'><t t-esc='label.value'/></option>
|
||||
</t>
|
||||
<t t-if='question.comments_allowed and question.comment_count_as_answer'>
|
||||
<option class="js_other_option" value="-1"><span t-esc="question.comment_children_ids[0].question" /></option>
|
||||
<option class="js_other_option" value="-1"><span t-esc="question.comments_message" /></option>
|
||||
</t>
|
||||
</select>
|
||||
</div>
|
||||
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="col-md-6">
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
|
||||
</div>
|
||||
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12 mt16">
|
||||
<span t-field="question.comment_children_ids[0].question"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
|
||||
<span t-field="question.comments_message"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="question.display_mode == 'columns' " class="row js_radio">
|
||||
|
@ -187,13 +187,13 @@
|
|||
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_comments col-md-12" >
|
||||
<label>
|
||||
<input type="radio" t-att-name="prefix" value="-1"/>
|
||||
<span t-field="question.comment_children_ids[0].question" />
|
||||
<span t-field="question.comments_message" />
|
||||
</label>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
|
||||
</div>
|
||||
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
|
||||
<span t-field="question.comment_children_ids[0].question"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
|
||||
<span t-field="question.comments_message"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -209,13 +209,13 @@
|
|||
<div t-if='question.comments_allowed and question.comment_count_as_answer' class="js_ck_comments col-md-12" >
|
||||
<label>
|
||||
<input type="checkbox" t-att-name="'%s_%s' % (prefix, -1)" value="-1" />
|
||||
<span t-field="question.comment_children_ids[0].question" />
|
||||
<span t-field="question.comments_message" />
|
||||
</label>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')"/>
|
||||
</div>
|
||||
<div t-if='question.comments_allowed and not question.comment_count_as_answer' class="col-md-12">
|
||||
<span t-field="question.comment_children_ids[0].question"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" data-oe-survey-othert="1"/>
|
||||
<span t-field="question.comments_message"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" data-oe-survey-othert="1"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -239,8 +239,8 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<div t-if='question.comments_allowed'>
|
||||
<span t-field="question.comment_children_ids[0].question"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, question.comment_children_ids[0].id)" />
|
||||
<span t-field="question.comments_message"/>
|
||||
<input type="text" class="form-control" t-att-name="'%s_%s' % (prefix, 'comment')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -255,13 +255,13 @@
|
|||
<div class="row">
|
||||
<div class='jumbotron mt32'>
|
||||
<h1><span t-field='survey.title'/></h1>
|
||||
<t t-if="survey.description is not False"><div t-field='survey.description'/></t>
|
||||
<t t-if="survey.description"><div t-field='survey.description'/></t>
|
||||
</div>
|
||||
<form role="form" method="post" class="js_surveyform" t-att-name="'%s' % (survey.id)" t-att-data-prefill="'/survey/prefill/%s/%s' % (slug(survey), token)">
|
||||
<t t-foreach="survey.page_ids" t-as="page">
|
||||
<div class="page-header">
|
||||
<h1 t-field='page.title' />
|
||||
<div t-field='page.description'/>
|
||||
<t t-if="page.description"><div t-field='page.description'/></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)" />
|
||||
|
@ -270,7 +270,7 @@
|
|||
<span t-field='question.question' />
|
||||
<span t-if="question.constr_mandatory" class="text-danger">*</span>
|
||||
</h2>
|
||||
<p class="text-muted"><t t-if="question.description"><span t-field='question.description'/></t></p>
|
||||
<t t-if="question.description"><div class="text-muted" 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>
|
||||
|
|
Loading…
Reference in New Issue