From c03ffffa8a02da44a91b354cc6f04fd658a905e2 Mon Sep 17 00:00:00 2001 From: "Turkesh Patel (Open ERP)" Date: Wed, 12 Mar 2014 15:24:13 +0530 Subject: [PATCH] [IMP] instead of using len(question.child_ids) use child_count, remove forum filed from gamification.badge use only level, rename controller from /badges to /badge and /tags to /tag bzr revid: tpa@tinyerp.com-20140312095413-23d39ir8txd3f35q --- addons/website_forum/controllers/main.py | 11 +++---- .../website_forum/data/forum_badges_data.xml | 32 ------------------- addons/website_forum/models/website_forum.py | 6 ++-- addons/website_forum/views/website_forum.xml | 20 ++++++------ 4 files changed, 17 insertions(+), 52 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index c40f8b23a34..0509cd348ef 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -253,10 +253,9 @@ class website_forum(http.Controller): def tag_questions(self, forum, tag, page=1, **kwargs): cr, uid, context = request.cr, request.uid, request.context Post = request.registry['website.forum.post'] - post_ids = [que.id for que in tag.post_ids] - obj_ids = Post.search(cr, uid, [('forum_id', '=', forum.id), ('id', 'in', post_ids)], context=context) + obj_ids = Post.search(cr, uid, [('forum_id', '=', forum.id), ('tags', '=', tag.id)], context=context) question_ids = Post.browse(cr, uid, obj_ids, context=context) - pager = request.website.pager(url="/forum/%s/tag" % slug(forum), total=len(tag.post_ids), page=page, step=10, scope=10) + pager = request.website.pager(url="/forum/%s/tag" % slug(forum), total=len(obj_ids), page=page, step=10, scope=10) kwargs['tags'] = 'True' values = { @@ -267,7 +266,7 @@ class website_forum(http.Controller): } return request.website.render("website_forum.index", values) - @http.route(['/forum//tags'], type='http', auth="public", website=True, multilang=True) + @http.route(['/forum//tag'], type='http', auth="public", website=True, multilang=True) def tags(self, forum, page=1, **searches): cr, uid, context = request.cr, request.uid, request.context Tag = request.registry['website.forum.tag'] @@ -280,11 +279,11 @@ class website_forum(http.Controller): } return request.website.render("website_forum.tag", values) - @http.route(['/forum//badges'], type='http', auth="public", website=True, multilang=True) + @http.route(['/forum//badge'], type='http', auth="public", website=True, multilang=True) def badges(self, forum, **searches): cr, uid, context = request.cr, request.uid, request.context Badge = request.registry['gamification.badge'] - badge_ids = Badge.search(cr, uid, [('forum', '=', True)], context=context) + badge_ids = Badge.search(cr, uid, [('level', '!=', False)], context=context) badges = Badge.browse(cr, uid, badge_ids, context=context) values = { 'badges': badges, diff --git a/addons/website_forum/data/forum_badges_data.xml b/addons/website_forum/data/forum_badges_data.xml index 1689a3c5092..b9156289684 100644 --- a/addons/website_forum/data/forum_badges_data.xml +++ b/addons/website_forum/data/forum_badges_data.xml @@ -7,222 +7,190 @@ Autobiographer Completed own biography - True bronze Cleanup First rollback - True gold Commentator Posted 10 comments - True gold Critic First downvote - True gold Disciplined Deleted own post with 3 or more upvotes - True gold Editor First edit - True gold Enlightened First answer was accepted with 3 or more votes - True silver Enthusiast Voted on questions/answers for 15 days in a row - True silver Expert Posted more than 10 questions or answers in one tag - True silver Famous Question Asked a question with 500 views - True gold Favorite Question Question favorited by 5 users - True silver Good Answer Answer voted up 6 times - True silver Good Question Question voted up 6 times - True silver Great Answer Answer voted up 15 times - True gold Great Question Question voted up 15 times - True gold Guru Answer accepted with 15 or more votes - True silver Necromancer Answered a question more than 30 days later with at least 2 votes - True silver Nice Answer Answer voted up 4 times - True bronze Nice Quesiotn Question voted up 4 times - True bronze Notable Question Asked a question with 250 views - True silver Organizer First retag - True bronze Peer Pressure Deleted own post with 3 or more downvotes - True gold Popular Question Asked a question with 150 views - True gold Pundit Left 10 comments with score of 10 or more - True silver Scholar Asked a question and accepted an answer - True gold self-Learner Answered own question with at least 4 up votes - True gold Stellar Question Question favorited by 25 users - True bronze Associate Editor Edited 30 entries - True silver Student Asked first question with at least one up vote - True gold Supporter First upvote - True gold Taxonomist Created a tag used by 15 questions - True silver Teacher Received at least 3 upvote for an answer for the first time - True gold diff --git a/addons/website_forum/models/website_forum.py b/addons/website_forum/models/website_forum.py index 16b32e3c037..64e34c654f9 100644 --- a/addons/website_forum/models/website_forum.py +++ b/addons/website_forum/models/website_forum.py @@ -228,7 +228,7 @@ class PostHistory(osv.Model): _description = 'Post History' _inherit = ['website.seo.metadata'] _columns = { - 'name': fields.char('Post Title') + 'name': fields.char('Post Title'), 'post_id': fields.many2one('website.forum.post', 'Post', ondelete='cascade'), 'date': fields.datetime('Created on', select=True, readonly=True), 'user_id': fields.many2one('res.users', 'Created by', select=True, readonly=True), @@ -267,7 +267,7 @@ class Vote(osv.Model): vote_ids = self.search(cr, uid, [('post_id', '=', post_id), ('user_id','=',uid)], context=context) if vote_ids: self.write(cr, uid, vote_uid, { - 'vote': vote) + 'vote': vote }, context=context) else: self.create(cr, uid, { @@ -279,8 +279,6 @@ class Vote(osv.Model): class Badge(osv.Model): _inherit = 'gamification.badge' _columns = { - # TODO: remove this forum field and use level is not False instead - 'forum': fields.boolean('Is a Forum Badge'), 'level': fields.selection([('bronze', 'bronze'), ('silver', 'silver'), ('gold', 'gold')], 'Forum Badge Level'), } diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index deb6db1efc6..7637374268e 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -35,10 +35,10 @@