From f7e6f1792feb1ddd94edff31facb3784fa48d8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 10 Apr 2014 15:38:12 +0200 Subject: [PATCH] [IMP] website_forum: first pass of cleaning badges + separated into separate files bzr revid: tde@openerp.com-20140410133812-qa6z3u3oq8q70zdb --- addons/website_forum/__openerp__.py | 6 +- addons/website_forum/data/badges_answer.xml | 263 ++++++++++++++ .../website_forum/data/badges_moderation.xml | 304 ++++++++++++++++ .../data/badges_participation.xml | 208 +++++++++++ addons/website_forum/data/badges_question.xml | 343 ++++++++++++++++++ 5 files changed, 1122 insertions(+), 2 deletions(-) create mode 100644 addons/website_forum/data/badges_answer.xml create mode 100644 addons/website_forum/data/badges_moderation.xml create mode 100644 addons/website_forum/data/badges_participation.xml create mode 100644 addons/website_forum/data/badges_question.xml diff --git a/addons/website_forum/__openerp__.py b/addons/website_forum/__openerp__.py index a4b38be826f..439c3df15a4 100644 --- a/addons/website_forum/__openerp__.py +++ b/addons/website_forum/__openerp__.py @@ -40,8 +40,10 @@ Ask questions, get answers, no distractions 'views/res_users.xml', 'views/website_forum.xml', 'security/ir.model.access.csv', - 'security/website_forum.xml', - 'data/forum_badges_data.xml', + 'data/badges_question.xml', + 'data/badges_answer.xml', + 'data/badges_participation.xml', + 'data/badges_moderation.xml', ], 'qweb': [ 'static/src/xml/*.xml' diff --git a/addons/website_forum/data/badges_answer.xml b/addons/website_forum/data/badges_answer.xml new file mode 100644 index 00000000000..bc4af4700c5 --- /dev/null +++ b/addons/website_forum/data/badges_answer.xml @@ -0,0 +1,263 @@ + + + + + + + + Teacher + Received at least 3 upvote for an answer for the first time + bronze + + + Teacher + Received at least 3 upvote for an answer for the first time + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3)] + higher + + + Teacher + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Nice Answer + Answer voted up 4 times + bronze + + + Nice Answer + Answer voted up 4 times + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 4)] + higher + + + Nice Answer + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Good Answer + Answer voted up 6 times + silver + + + Good Answer + Answer voted up 6 times + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 6)] + higher + + + Good Answer + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Great Answer + Answer voted up 15 times + gold + + + Great Answer + Answer voted up 15 times + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15)] + higher + + + Great Answer + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + Enlightened + Answer was accepted with 3 or more votes + silver + + + Enlightened + Answer was accepted with 3 or more votes + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3), ('is_correct', '=', True)] + higher + + + Enlightened + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Guru + Answer accepted with 15 or more votes + silver + + + Guru + Answer accepted with 15 or more votes + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15), ('is_correct', '=', True)] + higher + + + Great Answer + once + personal + never + + + inprogress + forum + + + + 1 + + + + + + + + + Self-Learner + Answered own question with at least 4 up votes + gold + + + Self-Learner + Answere own question with at least 4 up votes + count + boolean + + [('user_id', '=', user.id), ('parent_id', '!=', False), ('parent_id.user_id', '=', user.id), ('vote_count', '>=', 3)] + higher + + + Self-Learner + once + personal + never + + + inprogress + forum + + + + 1 + + + + + \ No newline at end of file diff --git a/addons/website_forum/data/badges_moderation.xml b/addons/website_forum/data/badges_moderation.xml new file mode 100644 index 00000000000..dde6bd30196 --- /dev/null +++ b/addons/website_forum/data/badges_moderation.xml @@ -0,0 +1,304 @@ + + + + + + + + + + Critic + First downvote + bronze + + + Critic + First downvote + count + boolean + + [('user_id', '=', user.id), ('vote', '=', '-1')] + higher + + + Critic + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + Disciplined + Deleted own post with 3 or more upvotes + bronze + + + Disciplined + Delete own post with 3 or more upvotes + count + boolean + + [('user_id', '=', user.id), ('vote_count', '>=', 3), ('active', '=', False)] + higher + + + Disciplined + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enthusiast + Voted on questions/answers for 15 days in a row + silver + + + Enthusiast + Vote on questions/answers for 15 days in a row + python + start_date = date.today() - timedelta(days=16) +end_date = date.today() - timedelta(days=1) +cr.execute('SELECT COUNT(id), create_date from forum_post_vote where create_date >= %s and create_date <= %s and user_id = %s GROUP BY create_date',(start_date,end_date, object.user_id.id,)) +data = cr.dictfetchall() +result = int(len(data) >= 15) + + boolean + higher + + + Enthusiast + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Supporter + First upvote + gold + + + + Supporter + First upwnvote + count + boolean + + [('user_id','=',user.id), ('vote', '=', '1')] + higher + + + + Supporter + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + Peer Pressure + Deleted own post with 3 or more downvotes + gold + + + + Peer Pressure + Delete own post with 3 or more down votes + count + boolean + + [('user_id','=',user.id), ('vote_count', '<=', -3), ('active', '=', False)] + higher + + + + Peer Pressure + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + \ No newline at end of file diff --git a/addons/website_forum/data/badges_participation.xml b/addons/website_forum/data/badges_participation.xml new file mode 100644 index 00000000000..c70a787b286 --- /dev/null +++ b/addons/website_forum/data/badges_participation.xml @@ -0,0 +1,208 @@ + + + + + + + Autobiographer + Completed own biography + bronze + + + Completed own biography + Write some information about your self + count + boolean + + [('id','=',user.id), +('partner_id.country_id', '!=', False), +('partner_id.city', '!=', False), +('partner_id.email', '!=', False)] + higher + + + Complete own biography + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/addons/website_forum/data/badges_question.xml b/addons/website_forum/data/badges_question.xml new file mode 100644 index 00000000000..d012fdb7734 --- /dev/null +++ b/addons/website_forum/data/badges_question.xml @@ -0,0 +1,343 @@ + + + + + + + + Popular Question + Asked a question with at least 150 views + bronze + + + Popular Question + Asked a question with at least 150 views + count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 150)] + higher + + + Popular Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Notable Question + Asked a question with at least 250 views + silver + + + Notable Question + Asked a question with at least 250 views + count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 250)] + higher + + + Notable Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Famous Question + Asked a question with at least 500 views + gold + + + Famous Question + Asked a question with at least 500 views + count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 500)] + higher + + + Famous Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + Credible Question + Question set as favorite by 1 user1 + bronze + + + Credible Question + Question set as favorite by 1 user + count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 1)] + higher + + + Credible Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Favorite Question + Question set as favorite by 5 users + silver + + + Favorite Question + Question set as favorite by 5 users + count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 5)] + higher + + + Favorite Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Stellar Question + Question set as favorite by 5 users + bronze + + + Stellar Question + Question set as favorite by 5 users +count + boolean + + [('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 25)] + higher + + + Stellar Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + + + Student + Asked first question with at least one up vote + gold + + + Student + Asked first question with at least one up vote + count + boolean + + [('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 1)] + higher + + + Student + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Nice Quesiotn + Question voted up 4 times + bronze + + + Nice Question + Question voted up 4 times + count + boolean + + [('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 4)] + higher + + + Nice Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Good Question + Question voted up 6 times + silver + + + Good Question + Question voted up 6 times + count + boolean + + [('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 6)] + higher + + + Good Question + once + personal + never + + + inprogress + forum + + + + + 1 + + + + Great Question + Question voted up 15 times + gold + + + Great Question + Question voted up 15 times + count + boolean + + [('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 15)] + higher + + + Great Question + once + personal + never + + + inprogress + forum + + + + 1 + + + + + + + + \ No newline at end of file