[IMP] add template of answers and improved code

bzr revid: tpa@tinyerp.com-20140224070206-pxxet6kfgpyftclc
This commit is contained in:
Turkesh Patel (Open ERP) 2014-02-24 12:32:06 +05:30
parent eb36ac6be1
commit 6721db92a6
2 changed files with 94 additions and 134 deletions

View File

@ -35,19 +35,19 @@ from openerp.addons.website.controllers.main import Website as controllers
controllers = controllers() controllers = controllers()
class website_forum(http.Controller): class website_forum(http.Controller):
@http.route(['/questions/', '/question/page/<int:page>'], type='http', auth="public", website=True, multilang=True) @http.route(['/questions/', '/question/page/<int:page>'], type='http', auth="public", website=True, multilang=True)
def questions(self, page=1, **searches): def questions(self, page=1, **searches):
cr, uid, context = request.cr, request.uid, request.context cr, uid, context = request.cr, request.uid, request.context
forum_obj = request.registry['website.forum.post'] forum_obj = request.registry['website.forum.post']
tag_obj = request.registry['website.forum.tag'] tag_obj = request.registry['website.forum.tag']
step = 5 step = 5
question_count = forum_obj.search( question_count = forum_obj.search(
request.cr, request.uid, [], count=True, request.cr, request.uid, [], count=True,
context=request.context) context=request.context)
pager = request.website.pager(url="/questions/", total=question_count, page=page, step=step, scope=5) pager = request.website.pager(url="/questions/", total=question_count, page=page, step=step, scope=5)
obj_ids = forum_obj.search( obj_ids = forum_obj.search(
request.cr, request.uid, [], limit=step, request.cr, request.uid, [], limit=step,
offset=pager['offset'], context=request.context) offset=pager['offset'], context=request.context)
@ -69,20 +69,20 @@ class website_forum(http.Controller):
} }
return request.website.render(page, values) return request.website.render(page, values)
# @http.route(['/question/<model("website.forum.post"):question>'], type='http', auth="public", website=True, multilang=True) @http.route(['/question/<model("website.forum.post"):question>'], type='http', auth="public", website=True, multilang=True)
# def question_register(self, question, **post): def question_register(self, question, **post):
# values = { values = {
# 'question': question, 'question': question,
# 'main_object': question, 'main_object': question,
# 'range': range, 'range': range,
# } }
# return request.website.render("website_forum.question_description_full", values) return request.website.render("website_forum.question_description_full", values)
@http.route('/question/postquestion/', type='http', auth="user", multilang=True, website=True) @http.route('/question/postquestion/', type='http', auth="user", multilang=True, website=True)
def post_question(self, question_name="New question", **kwargs): def post_question(self, question_name="New question", **kwargs):
#TODO : reply a page that allows user to post a question #TODO : reply a page that allows user to post a question
return self._add_question(question_name, request.context, **kwargs) return self._add_question(question_name, request.context, **kwargs)
@http.route('/question/new/', type='http', auth="user", multilang=True, methods=['POST'], website=True) @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
@ -97,7 +97,7 @@ class website_forum(http.Controller):
'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/new/', 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

View File

@ -67,35 +67,59 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-3">
<h5> <h5>
<span itemprop="Votes" class="label label-success"> <span itemprop="Votes" class="label label-success">
<t t-esc="len(question.vote_ids)" /> <t t-esc="len(question.vote_ids)" />
Votes Votes
</span> </span>
</h5> </h5>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-3">
<h5> <h5>
<span itemprop="Votes" class="label label-success"> <span itemprop="Votes" class="label label-success">
<t t-esc="len(question.vote_ids)" /> <t t-esc="len(question.vote_ids)" />
Answers Answers
</span> </span>
</h5> </h5>
</div> </div>
<div class="col-xs-3"> <div class="col-xs-3">
<h5> <h5>
<span itemprop="Votes" class="label label-success"> <span itemprop="Votes" class="label label-success">
<t t-esc="question.views" /> <t t-esc="question.views" />
Views Views
</span> </span>
</h5> </h5>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<template id="answer">
<div class="row">
<t t-call="website_forum.question_vote" />
<div class="col-md-9 col-xs-10">
<div class="row">
<div class="col-xs-12">
<span>
<h6>
There should be a call to the cash drawers API. Read the
technical
manual of the hardware you are using. Thanks.
</h6>
</span>
</div>
</div>
<div class="row">
<t t-call="website_forum.user_detail" />
</div>
<t t-call="website_forum.question_links" />
<t t-call="website_forum.question_vote" />
</div>
</div>
</template>
<template id="question_search"> <template id="question_search">
<form class="navbar-form " role="search"> <form class="navbar-form " role="search">
@ -222,25 +246,27 @@
</template> </template>
<template id="question_vote"> <template id="question_vote">
<div class="col-md-1 col-xs-1"> <div class="row">
<div class="row"> <div class="col-md-1 col-xs-1">
<div class="col-xs-12 custom-arrow-height"> <div class="row">
<span class="glyphicon glyphicon-chevron-up" /> <div class="col-xs-12 custom-arrow-height">
</div> <span class="glyphicon glyphicon-chevron-up" />
</div> </div>
<div class="row"> </div>
<div class="col-xs-12 custom-vote-height"> <div class="row">
<h4> <div class="col-xs-12 custom-vote-height">
<span>0</span> <h4>
</h4> <span>0</span>
</div> </h4>
</div> </div>
<div class="row"> </div>
<div class="col-xs-12 custom-arrow-height"> <div class="row">
<span class="glyphicon glyphicon-chevron-down" /> <div class="col-xs-12 custom-arrow-height">
</div> <span class="glyphicon glyphicon-chevron-down" />
</div> </div>
</div> </div>
</div>
</div>
</template> </template>
<template id="question_links"> <template id="question_links">
@ -267,8 +293,9 @@
<t t-call="website.layout"> <t t-call="website.layout">
<t t-call="website_forum.question_search" /> <t t-call="website_forum.question_search" />
<div class="container MainBody"> <div class="container MainBody">
<t t-call="website_forum.question_vote" />
<div class="row"> <div class="row">
<t t-call="website_forum.question_vote" />
<div class="col-md-9 col-xs-11"> <div class="col-md-9 col-xs-11">
<div class="row"> <div class="row">
@ -286,26 +313,9 @@
<span class="badge">cash</span> <span class="badge">cash</span>
</div> </div>
</div> </div>
<hr />
<div class="row">
<div class="col-xs-12">
<span>
<h6>
How to send some signal to cash drawer to open it after
click
print receipt or something similar? I don't know whether
this
depends on cash drawer's driver or not ?
</h6>
</span>
</div>
</div>
<div class="row">
<t t-call="website_forum.user_detail" />
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-12 page-header"> <div class="col-xs-12 page-header">
<span class="badge">2 Answers</span> <span class="badge">2 Answers</span>
@ -326,64 +336,14 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="row"> <ul class="media-list">
<t t-call="website_forum.question_vote" /> <li t-foreach="question.child_ids" t-as="answer" class="media">
<div class="col-md-9 col-xs-10"> <t t-call="website_forum.answer" />
<div class="row"> </li>
<div class="col-xs-12"> <t t-call="website_forum.answer" />
<span> </ul>
<h6>
There should be a call to the cash drawers API. Read the
technical
manual of the hardware you are using. Thanks.
</h6>
</span>
</div>
</div>
<div class="row">
<t t-call="website_forum.user_detail" />
</div>
<t t-call="website_forum.question_links" />
</div>
</div>
<hr />
<div class="row">
<t t-call="website_forum.question_vote" />
</div>
<div class="col-md-9 col-xs-10">
<div class="row">
<div class="col-xs-12">
<span>
<h6>
Usually the cash drawer behaves like a printer in the sense
that it
has a RS232 or USB port. However the cash drawer is
dummy and
only uses the port to receive a signal (positive
voltage)
which causes it to open.
So you only need send any
signal to the RS232 or USB port (like
for insance print the
ascii character "a" to the rs232 port)
and it will open!. I the
old days you could test it from
hyperterminal, I guess nowadays
you will have to make a
javascript app that sends a character
to the rs232 port.
</h6>
</span>
</div>
</div>
<div class="row">
<t t-call="website_forum.user_detail" />
</div>
<t t-call="website_forum.question_links" />
</div>
</div> </div>
</t> </t>
</template> </template>