[MRG] merge with https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-website-forum-tpa-imp2-ssh, improved some comments
bzr revid: tpa@tinyerp.com-20140318120659-mn87lrd0ppcbt8t8
This commit is contained in:
commit
603cc77da7
|
@ -162,6 +162,7 @@ class website_forum(http.Controller):
|
|||
Activity = request.registry['mail.message']
|
||||
Data = request.registry["ir.model.data"]
|
||||
|
||||
#questions asked by user.
|
||||
question_ids = Post.search(cr, uid, [('forum_id', '=', forum.id), ('create_uid', '=', user.id), ('parent_id', '=', False)], context=context)
|
||||
user_questions = Post.browse(cr, uid, question_ids, context=context)
|
||||
|
||||
|
@ -170,16 +171,21 @@ class website_forum(http.Controller):
|
|||
user_answers = Post.browse(cr, uid, obj_ids, context=context)
|
||||
answers = [answer.parent_id for answer in user_answers]
|
||||
|
||||
#votes which given on users questions and answers.
|
||||
total_votes = Vote.search(cr, uid, [('post_id.forum_id', '=', forum.id), ('post_id.create_uid', '=', user.id)], count=True, context=context)
|
||||
up_votes = Vote.search(cr, uid, [('post_id.forum_id', '=', forum.id), ('post_id.create_uid', '=', user.id), ('vote', '=', '1')], count=True, context=context)
|
||||
down_votes = Vote.search(cr, uid, [('post_id.forum_id', '=', forum.id), ('post_id.create_uid', '=', user.id), ('vote', '=', '-1')], count=True, context=context)
|
||||
|
||||
#Votes which given by users on others questions and answers.
|
||||
post_votes = Vote.search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
vote_ids = Vote.browse(cr, uid, post_votes, context=context)
|
||||
|
||||
#activity by user.
|
||||
user_post_ids = question_ids + obj_ids
|
||||
model, comment = Data.get_object_reference(cr, uid, 'mail', 'mt_comment')
|
||||
activity_ids = Activity.search(cr, uid, [('res_id', 'in', user_post_ids), ('model', '=', 'website.forum.post'), '|', ('subtype_id', '!=', comment), ('subtype_id', '=', False)], context=context)
|
||||
activities = Activity.browse(cr, uid, activity_ids, context=context)
|
||||
|
||||
|
||||
posts = {}
|
||||
for act in activities:
|
||||
posts[act.res_id] = True
|
||||
|
@ -200,7 +206,8 @@ class website_forum(http.Controller):
|
|||
'up_votes': up_votes,
|
||||
'down_votes': down_votes,
|
||||
'activities': activities,
|
||||
'posts': posts
|
||||
'posts': posts,
|
||||
'vote_post':vote_ids,
|
||||
}
|
||||
return request.website.render("website_forum.user_detail_full", values)
|
||||
|
||||
|
|
|
@ -656,6 +656,9 @@
|
|||
<li>
|
||||
<a href="#followed_question" data-toggle="tab">Followed Question</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#votes" data-toggle="tab">Votes</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content mt16">
|
||||
<div class="tab-pane active" id="questions">
|
||||
|
@ -676,6 +679,9 @@
|
|||
<div class="tab-pane" id="followed_question">
|
||||
<h1>Followed Questions</h1>
|
||||
</div>
|
||||
<div class="tab-pane" id="votes">
|
||||
<t t-call="website_forum.user_votes"/>
|
||||
</div>
|
||||
<div class="tab-pane" id="activity">
|
||||
<ul class="list-unstyled">
|
||||
<li t-foreach="activities" t-as="activity">
|
||||
|
@ -714,5 +720,21 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<template id="user_votes">
|
||||
<div t-foreach="vote_post" t-as="vote">
|
||||
<t t-esc="vote.post_id.create_date"/>
|
||||
<span t-if="vote.vote == '1'" class="fa fa-thumbs-up text-success" style="margin-left:30px"/>
|
||||
<span t-if="vote.vote == '-1'" class="fa fa-thumbs-down text-warning" style="margin-left:30px"/>
|
||||
<t t-if="vote.post_id.parent_id">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/question/#{ vote.post_id.parent_id.id }/#answer-#{ vote.post_id.id }" t-esc="vote.post_id.parent_id.name" style="margin-left:10px"/>
|
||||
</t>
|
||||
<t t-if="not vote.post_id.parent_id">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/question/#{ vote.post_id.id }" style=" color:black;margin-left:10px" t-esc="vote.post_id.name"/>
|
||||
</t>
|
||||
</div>
|
||||
<div class="mb16" t-if="not vote_post">
|
||||
<b>No vote given by you yet!</b>
|
||||
</div>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue