[IMP] improved code, not show challanges assinged to user for forum.

bzr revid: tpa@tinyerp.com-20140328090357-gm5qjza4hchbet0i
This commit is contained in:
Turkesh Patel (Open ERP) 2014-03-28 14:33:57 +05:30
parent df99f0e818
commit 1c4180c0f3
5 changed files with 33 additions and 15 deletions

View File

@ -236,6 +236,7 @@ class website_forum(http.Controller):
#votes which given on users questions and answers.
data = Vote.read_group(cr, uid, [('post_id.forum_id', '=', forum.id), ('post_id.user_id', '=', user.id)], ["vote"], groupby=["vote"], context=context)
up_votes, down_votes = 0, 0
for rec in data:
if rec['vote'] == '1':
up_votes = rec['vote_count']

View File

@ -116,9 +116,6 @@
</tr><tr>
<td class="faq-rep-item"><strong>300</strong></td>
<td>edit any post, view offensive flags</td>
</tr><tr>
<td class="faq-rep-item"><strong>400</strong></td>
<td>delete any comment</td>
</tr><tr>
<td class="faq-rep-item"><strong>500</strong></td>
<td>accept any answer (after 1 week)</td>

View File

@ -33,10 +33,26 @@ class Forum(osv.Model):
_name = 'website.forum'
_description = 'Forums'
_inherit = ['mail.thread', 'website.seo.metadata']
def _get_right_column(self, cr, uid, ids, field_name, arg, context):
res = {}
for forum in self.browse(cr, uid, ids, context=context):
res[forum.id] = """<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">About This Forum</h3>
</div>
<div class="panel-body">
This community is for professionals and enthusiasts of our
products and services.<br/>
<a href="/forum/%s/faq" class="fa fa-arrow-right"> Read Guidelines</a>
</div>
</div>""" % slug(forum)
return res
_columns = {
'name': fields.char('Name', required=True, translate=True),
'faq': fields.html('Guidelines'),
'right_column': fields.html('Right Column'),
'right_column':fields.function(_get_right_column, string="Right Column", type='html', store=True),
}
def _get_default_faq(self, cr, uid, context={}):
fname = openerp.modules.get_module_resource('website_forum', 'data', 'forum_default_faq.html')
@ -46,16 +62,6 @@ class Forum(osv.Model):
_defaults = {
'faq': _get_default_faq,
'right_column': """<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">About This Forum</h3>
</div>
<div class="panel-body">
This community is for professionals and enthusiasts of our
products and services.<br/>
<a t-attf-href="/forum/1/faq" class="fa fa-arrow-right"> Read Guidelines</a>
</div>
</div>"""
}
class Post(osv.Model):

View File

@ -19,6 +19,7 @@
#
##############################################################################
import copy
import openerp
from openerp.osv import osv, fields
from openerp.tools.translate import _
@ -70,3 +71,16 @@ class Badge(osv.Model):
'level': fields.selection([('bronze', 'bronze'), ('silver', 'silver'), ('gold', 'gold')], 'Forum Badge Level'),
}
class Users(osv.Model):
_inherit = 'res.users'
def _serialised_goals_summary(self, cr, uid, user_id, context=None):
"""Do not show forum challenges in user inbox side panel."""
all_goals_info = super(Users, self)._serialised_goals_summary(cr, uid, user_id, context=context)
goals_info = copy.copy(all_goals_info)
challenge_obj = self.pool['gamification.challenge']
for goal in all_goals_info:
challenge = challenge_obj.browse(cr, uid, goal['id'], context=context)
if challenge.category == 'forum':
goals_info.remove(goal)
return goals_info

View File

@ -849,7 +849,7 @@
<div t-esc="len(answer.vote_ids)"/>
</div>
<div class="question-name" style="margin-left: 32px;">
<a style="font-size: 15px;" t-attf-href="/forum/#{ slug(forum) }/question/#{ answer.parent_id.id }/#answer-#{ answer.id }" t-esc="answer.name"/>
<a style="font-size: 15px;" t-attf-href="/forum/#{ slug(forum) }/question/#{ answer.parent_id.id }/#answer-#{ answer.id }" t-esc="answer.parent_id.name"/>
<t t-if="len(answer.website_message_ids)&gt;0">
(<t t-esc="len(answer.website_message_ids)"/>
<t t-if="len(answer.website_message_ids)&gt;1">Comments</t>