[ADD] add template to ask qestion and relatedd code.
bzr revid: tpa@tinyerp.com-20140225093418-xab0yv4tqz4yx0u2
This commit is contained in:
parent
615d5c4ab8
commit
837a43926e
|
@ -58,6 +58,13 @@ class website_forum(http.Controller):
|
||||||
offset=pager['offset'], context=request.context)
|
offset=pager['offset'], context=request.context)
|
||||||
question_ids = forum_obj.browse(request.cr, request.uid, obj_ids,
|
question_ids = forum_obj.browse(request.cr, request.uid, obj_ids,
|
||||||
context=request.context)
|
context=request.context)
|
||||||
|
#If dose not get any related question then redirect to ask question form.
|
||||||
|
if search and not question_ids:
|
||||||
|
values = {
|
||||||
|
'question_name': search,
|
||||||
|
}
|
||||||
|
return request.website.render("website_forum.ask_question", values)
|
||||||
|
|
||||||
values = {
|
values = {
|
||||||
'total_questions': question_count,
|
'total_questions': question_count,
|
||||||
'question_ids': question_ids,
|
'question_ids': question_ids,
|
||||||
|
@ -85,31 +92,26 @@ class website_forum(http.Controller):
|
||||||
}
|
}
|
||||||
return request.website.render("website_forum.post_description_full", values)
|
return request.website.render("website_forum.post_description_full", values)
|
||||||
|
|
||||||
@http.route('/question/postquestion/', type='http', auth="user", multilang=True, website=True)
|
@http.route('/question/ask/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
||||||
def post_question(self, question_name="New question", **kwargs):
|
|
||||||
#TODO : reply a page that allows user to post a question
|
|
||||||
return self._add_question(question_name, request.context, **kwargs)
|
|
||||||
|
|
||||||
@http.route('/question/new/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
|
||||||
def register_question(self, forum_id=1, **question):
|
def register_question(self, forum_id=1, **question):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
create_context = dict(context)
|
create_context = dict(context)
|
||||||
new_question_id = request.registry['blog.post'].create(
|
new_question_id = request.registry['website.forum.post'].create(
|
||||||
request.cr, request.uid, {
|
request.cr, request.uid, {
|
||||||
'forum_id': forum_id,
|
#'forum_id': forum_id,
|
||||||
'name': question.get('name'),
|
'name': question.get('question_name'),
|
||||||
'content': question.get('content'),
|
'content': question.get('question_content'),
|
||||||
'tags' : question.get('tags'),
|
#'tags' : question.get('question_tags'),
|
||||||
'state': 'active',
|
'state': 'active',
|
||||||
'active': True,
|
'active': True,
|
||||||
}, context=create_context)
|
}, context=create_context)
|
||||||
return werkzeug.utils.redirect("/question/%s" % new_question_id)
|
return werkzeug.utils.redirect("/question/%s" % new_question_id)
|
||||||
|
|
||||||
@http.route('/question/new/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
@http.route('/question/postanswer/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
||||||
def post_answer(self, post_id, forum_id=1, **question):
|
def post_answer(self, post_id, forum_id=1, **question):
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
create_context = dict(context)
|
create_context = dict(context)
|
||||||
new_question_id = request.registry['blog.post'].create(
|
new_question_id = request.registry['website.forum.post'].create(
|
||||||
request.cr, request.uid, {
|
request.cr, request.uid, {
|
||||||
'forum_id': forum_id,
|
'forum_id': forum_id,
|
||||||
'parent_id':post_id,
|
'parent_id':post_id,
|
||||||
|
|
|
@ -304,6 +304,60 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template id="ask_question">
|
||||||
|
<t t-call="website.layout">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="page-header">
|
||||||
|
<h3>Please Ask your Question here</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
please, try to make your question interesting to others
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
provide enough details and, if possible, give an example
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
be clear and concise, avoid unnecessary introductions (Hi, ... Thanks...)
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<form action="/question/ask/" method="post" role="form">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<input type="text" name="question_name" required="True" t-attf-value="#{question_name or ''}" id="textbox_user_question" class="form-control" placeholder="Enter your Question" />
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
Please enter a descriptive question (should finish by a '?')
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<textarea name="question_content" required="True" t-attf-value="#{question_content or ''}" class="form-control" id="textarea_ckeditor" rows="10" style="width : 100%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
Tags:
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<input type="text" name="question_tag" t-attf-value="#{question_tag or ''}" class="form-control" id="textarea_tags" style="width : 100%"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<button class="btn btn-default form-control" id="btn_ask_your_question">Ask Your Question</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" >
|
||||||
|
CKEDITOR.replace("textarea_ckeditor");
|
||||||
|
</script>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template id="post_description_full">
|
<template id="post_description_full">
|
||||||
<t t-call="website.layout">
|
<t t-call="website.layout">
|
||||||
<t t-call="website_forum.post_search" />
|
<t t-call="website_forum.post_search" />
|
||||||
|
|
Loading…
Reference in New Issue