[IMP] add template for tags and controller to show questions related to that tag

bzr revid: tpa@tinyerp.com-20140224103256-goyi1u23x9u9vpua
This commit is contained in:
Turkesh Patel (Open ERP)
2014-02-24 16:02:56 +05:30
parent fab04b7f77
commit 256ccb2f18
5 changed files with 62 additions and 27 deletions
-4
View File
@@ -35,7 +35,6 @@ import werkzeug.urls
class website_event(http.Controller):
@http.route(['/event/', '/event/page/<int:page>'], type='http', auth="public", website=True, multilang=True)
def events(self, page=1, **searches):
print "events----------------",self,page,searches
cr, uid, context = request.cr, request.uid, request.context
event_obj = request.registry['event.event']
type_obj = request.registry['event.type']
@@ -163,7 +162,6 @@ class website_event(http.Controller):
@http.route(['/event/<model("event.event"):event>/page/<page:page>'], type='http', auth="public", website=True, multilang=True)
def event_page(self, event, page, **post):
print "event_page-------------------"
values = {
'event': event,
'main_object': event
@@ -172,7 +170,6 @@ class website_event(http.Controller):
@http.route(['/event/<model("event.event"):event>'], type='http', auth="public", website=True, multilang=True)
def event(self, event, **post):
print "in event---------------"
if event.menu_id and event.menu_id.child_id:
target_url = event.menu_id.child_id[0].url
else:
@@ -183,7 +180,6 @@ class website_event(http.Controller):
@http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True, multilang=True)
def event_register(self, event, **post):
print "event_register-------------------"
values = {
'event': event,
'main_object': event,
+1
View File
@@ -42,6 +42,7 @@ Ask questions, get answers, no distractions
'demo': [
'data/forum_demo.xml'
],
'css': ['static/src/css/website_forum.css'],
'installable': True,
'application': True,
}
+16 -3
View File
@@ -42,7 +42,7 @@ class website_forum(http.Controller):
forum_obj = request.registry['website.forum.post']
tag_obj = request.registry['website.forum.tag']
step = 5
step = 10
question_count = forum_obj.search(
request.cr, request.uid, [], count=True,
context=request.context)
@@ -70,7 +70,7 @@ class website_forum(http.Controller):
return request.website.render(page, values)
@http.route(['/question/<model("website.forum.post"):question>'], type='http', auth="public", website=True, multilang=True)
def question_register(self, question, **post):
def open_question(self, question, **post):
values = {
'question': question,
'main_object': question,
@@ -112,4 +112,17 @@ class website_forum(http.Controller):
'state': 'active',
'active': True,
}, context=create_context)
return werkzeug.utils.redirect("/question/%s" % post_id)
return werkzeug.utils.redirect("/question/%s" % post_id)
@http.route(['/questions/tag/<model("website.forum.tag"):tag>'], type='http', auth="public", website=True, multilang=True)
def tag_questions(self, tag, page=1, **kwargs):
cr, uid, context = request.cr, request.uid, request.context
step = 10
pager = request.website.pager(url="/questions/", total=len(tag.post_ids), page=page, step=step, scope=5)
values = {
'question_ids': tag.post_ids,
'pager': pager,
}
return request.website.render("website_forum.index", values)
+30
View File
@@ -256,5 +256,35 @@ Thank you in advance</field>
<field name="parent_id" ref="question_13" />
</record>
<record id="tags_0" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_0'))]"/>
</record>
<record id="tags_1" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_10'))]"/>
</record>
<record id="tags_2" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_9'))]"/>
</record>
<record id="tags_3" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_0'))]"/>
</record>
<record id="tags_4" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_0'))]"/>
</record>
<record id="tags_5" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_2'))]"/>
</record>
<record id="tags_6" model="website.forum.tag">
<field name="post_ids" eval="[(4,ref('website_forum.question_13'))]"/>
</record>
</data>
</openerp>
+15 -20
View File
@@ -34,18 +34,13 @@
<h4>
<a t-attf-href="/question/#{ slug(question) }">
<span>
<t t-esc="question.name" />
<t t-esc="question.name"/>
</span>
</a>
</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<a href="" class="badge">6.1</a>
<a href="" class="badge">7.0</a>
</div>
</div>
<t t-call="website_forum.tags" />
<div class="row">
<div class="col-xs-12 text-right">
<small>
@@ -96,6 +91,14 @@
</div>
</template>
<template id="tags">
<div class="col-xs-12">
<t t-foreach="question.tags" t-as="tag">
<a t-attf-href="/questions/tag/#{ tag.id }" class="badge"><t t-esc="tag.name"/></a>
</t>
</div>
</template>
<template id="answer">
<div class="row">
<t t-call="website_forum.question_vote" />
@@ -104,9 +107,7 @@
<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.
<t t-esc="question.name" />
</h6>
</span>
</div>
@@ -301,20 +302,15 @@
</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<span class="badge">openerp-7</span>
<span class="badge">pos</span>
<span class="badge">receipt</span>
<span class="badge">cash</span>
</div>
</div>
<t t-call="website_forum.tags" />
</div>
</div>
<div class="row">
<div class="col-xs-12 page-header">
<span class="badge">2 Answers</span>
<span class="badge">
<t t-esc="len(question.child_ids)"/> Answers
</span>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Short by
<b class="caret"></b>
@@ -337,7 +333,6 @@
<li t-foreach="question.child_ids" t-as="answer" class="media">
<t t-call="website_forum.answer" />
</li>
<t t-call="website_forum.answer" />
</ul>
</div>