[IMP] website_forum: first pass of cleaning badges + separated into separate files

bzr revid: tde@openerp.com-20140410133812-qa6z3u3oq8q70zdb
This commit is contained in:
Thibault Delavallée 2014-04-10 15:38:12 +02:00
parent e834e31bd9
commit f7e6f1792f
5 changed files with 1122 additions and 2 deletions

View File

@ -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'

View File

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- QUALITY (VOTES) -->
<!-- Teacher: at least 3 upvotes -->
<record id="badge_a_1" model="gamification.badge">
<field name="name">Teacher</field>
<field name="description">Received at least 3 upvote for an answer for the first time</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_teacher">
<field name="name">Teacher</field>
<field name="description">Received at least 3 upvote for an answer for the first time</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_teacher">
<field name="name">Teacher</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_1')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_teacher">
<field name="definition_id" eval="ref('definition_teacher')"/>
<field name="challenge_id" eval="ref('challenge_teacher')"/>
<field name="target_goal">1</field>
</record>
<!-- Nice: at least 4 upvotes -->
<record id="badge_a_2" model="gamification.badge">
<field name="name">Nice Answer</field>
<field name="description">Answer voted up 4 times</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_nice_answer">
<field name="name">Nice Answer</field>
<field name="description">Answer voted up 4 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 4)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_nice_answer">
<field name="name">Nice Answer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_2')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_nice_answer">
<field name="definition_id" eval="ref('definition_nice_answer')"/>
<field name="challenge_id" eval="ref('challenge_nice_answer')"/>
<field name="target_goal">1</field>
</record>
<!-- Good: at least 6 upvotes -->
<record id="badge_a_3" model="gamification.badge">
<field name="name">Good Answer</field>
<field name="description">Answer voted up 6 times</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_good_answer">
<field name="name">Good Answer</field>
<field name="description">Answer voted up 6 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 6)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_good_answer">
<field name="name">Good Answer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_3')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_good_answer">
<field name="definition_id" eval="ref('definition_good_answer')"/>
<field name="challenge_id" eval="ref('challenge_good_answer')"/>
<field name="target_goal">1</field>
</record>
<!-- Great: at least 15 upvotes -->
<record id="badge_a_4" model="gamification.badge">
<field name="name">Great Answer</field>
<field name="description">Answer voted up 15 times</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_great_answer">
<field name="name">Great Answer</field>
<field name="description">Answer voted up 15 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_great_answer">
<field name="name">Great Answer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_4')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_great_answer">
<field name="definition_id" eval="ref('definition_great_answer')"/>
<field name="challenge_id" eval="ref('challenge_great_answer')"/>
<field name="target_goal">1</field>
</record>
<!-- ACCEPTANCE -->
<!-- Enlightened: at least 3 upvotes for an accepted answer -->
<record id="badge_a_5" model="gamification.badge">
<field name="name">Enlightened</field>
<field name="description">Answer was accepted with 3 or more votes</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_enlightened">
<field name="name">Enlightened</field>
<field name="description">Answer was accepted with 3 or more votes</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')"/>
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 3), ('is_correct', '=', True)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_enlightened">
<field name="name">Enlightened</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_5')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_enlightened">
<field name="definition_id" eval="ref('definition_enlightened')"/>
<field name="challenge_id" eval="ref('challenge_enlightened')"/>
<field name="target_goal">1</field>
</record>
<!-- Guru: at least 15 upvotes for an accepted answer -->
<record id="badge_a_6" model="gamification.badge">
<field name="name">Guru</field>
<field name="description">Answer accepted with 15 or more votes</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_guru">
<field name="name">Guru</field>
<field name="description">Answer accepted with 15 or more votes</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('vote_count', '>=', 15), ('is_correct', '=', True)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_guru">
<field name="name">Great Answer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_6')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_guru">
<field name="definition_id" eval="ref('definition_guru')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_guru')" />
</record>
<!-- Necromancer: 30 days old question -->
<!-- <record id="badge_a_7" model="gamification.badge">
<field name="name">Necromancer</field>
<field name="description">Answered a question more than 30 days later with at least 2 votes</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_necromancer">
<field name="name">Necromancer</field>
<field name="description">Answered a question more than 30 days later with at least 2 votes</field>
<field name="computation_mode">python</field>
<field name="compute_code">def get_posts(cr, uid, context=None):
res = 1
Post = self.pool['website.forum.post']
user_posts = Post.search(cr, uid, [('user_id','=',object.user_id.id), ('parent_id', '!=', False), ('vote_count', '>=', 2)], context=context)
for post in Post.browse(cr, uid, user_posts, context=context):
print post.parent_id.create_date
question_date = datetime.strptime(post.parent_id.create_date, "%Y-%m-%d %H:%M:%S")
answer_date = datetime.strptime(post.create_date, "%Y-%m-%d %H:%M:%S")
if ((question_date - answer_date).days) >= 30:
res += 1
return res
result = get_posts(cr, uid, context=context)
</field>
<field name="display_mode">boolean</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_necromancer">
<field name="name">Necromancer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_18')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_necromancer">
<field name="definition_id" eval="ref('definition_necromancer')"/>
<field name="challenge_id" eval="ref('challenge_necromancer')"/>
<field name="target_goal">2</field>
</record> -->
<!-- Sealf Leaner: own question, 3+ upvotes -->
<record id="badge_a_8" model="gamification.badge">
<field name="name">Self-Learner</field>
<field name="description">Answered own question with at least 4 up votes</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_self_learner">
<field name="name">Self-Learner</field>
<field name="description">Answere own question with at least 4 up votes</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '!=', False), ('parent_id.user_id', '=', user.id), ('vote_count', '>=', 3)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_self_learner">
<field name="name">Self-Learner</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_a_8')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_self_learner">
<field name="definition_id" eval="ref('definition_self_learner')"/>
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_self_learner')"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,304 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Cleanup: answer or question edition -->
<!-- <record id="badge_3" model="gamification.badge">
<field name="name">Cleanup</field>
<field name="description">First rollback</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_cleanup">
<field name="name">Cleanup</field>
<field name="description">Edit answer or question</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('mail.model_mail_message')"/>
<field name="domain" eval="[('author_id', '=', user.partner_id.id), ('model', '=', 'forum.post'), ('subtype_id', 'in', [ref('website_forum.mt_answer_edit'), ref('website_forum.mt_question_edit')])]"/>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_cleanup">
<field name="name">Cleanup</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_3')"/>
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_cleanup">
<field name="definition_id" eval="ref('definition_cleanup')"/>
<field name="challenge_id" eval="ref('challenge_cleanup')"/>
<field name="target_goal">1</field>
</record> -->
<!-- Critic: downvote based -->
<record id="badge_5" model="gamification.badge">
<field name="name">Critic</field>
<field name="description">First downvote</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_critic">
<field name="name">Critic</field>
<field name="description">First downvote</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post_vote')"/>
<field name="domain">[('user_id', '=', user.id), ('vote', '=', '-1')]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_critic">
<field name="name">Critic</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_5')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_critic">
<field name="definition_id" eval="ref('definition_critic')"/>
<field name="challenge_id" eval="ref('challenge_critic')"/>
<field name="target_goal">1</field>
</record>
<!-- Disciplined: delete own post with >=3 upvotes -->
<record id="badge_6" model="gamification.badge">
<field name="name">Disciplined</field>
<field name="description">Deleted own post with 3 or more upvotes</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_disciplined">
<field name="name">Disciplined</field>
<field name="description">Delete own post with 3 or more upvotes</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('vote_count', '>=', 3), ('active', '=', False)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_disciplined">
<field name="name">Disciplined</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_6')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_disciplined">
<field name="definition_id" eval="ref('definition_disciplined')"/>
<field name="challenge_id" eval="ref('challenge_disciplined')"/>
<field name="target_goal">1</field>
</record>
<!-- Editor: first edit -->
<!-- <record id="badge_7" model="gamification.badge">
<field name="name">Editor</field>
<field name="description">First edit</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_editor">
<field name="name">Editor</field>
<field name="description">First edit of answer or question</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('mail.model_mail_message')" />
<field name="domain">[('user_id','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
<field name="domain" eval="[('author_id', '=', user.partner_id.id), ('model', '=', 'forum.post'), ('subtype_id', 'in', [ref('website_forum.mt_answer_edit'), ref('website_forum.mt_question_edit')])]"/>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_editor">
<field name="name">Editor</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_7')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_editor">
<field name="definition_id" eval="ref('definition_editor')"/>
<field name="challenge_id" eval="ref('challenge_editor')"/>
<field name="target_goal">1</field>
</record> -->
<!-- <record id="badge_22" model="gamification.badge">
<field name="name">Organizer</field>
<field name="description">First retag</field>
<field name="level">bronze</field>
</record> -->
<!-- <record model="gamification.goal.definition" id="definition_notable_question">
<field name="name">Organizer</field>
<field name="description">Your First retag</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_website_forum_post_history')" />
<field name="domain">[('user_id','=',user.id), ('tags','!=',False)]</field>
<field name="condition">higher</field>
</record> -->
<!-- <record model="gamification.challenge" id="challenge_notable_question">
<field name="name">Organizer</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_22')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record> -->
<!-- <record model="gamification.challenge.line" id="line_notable_question">
<field name="definition_id" eval="ref('definition_notable_question')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_notable_question')" />
</record> -->
<!-- <record id="badge_29" model="gamification.badge">
<field name="name">Associate Editor</field>
<field name="description">Edited 30 entries</field>
<field name="level">silver</field>
</record> -->
<!-- <record model="gamification.goal.definition" id="definition_associate_editor">
<field name="name">Associate Editor</field>
<field name="description">Edit 30 answer or question</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_website_forum_post_history')" />
<field name="domain">[('user_id','=',user.id), '|', ('name','!=',False), ('content','!=',False)]</field>
<field name="condition">higher</field>
</record> -->
<!-- <record model="gamification.challenge" id="challenge_associate_editor">
<field name="name">Associate Editor</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_29')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record> -->
<!-- <record model="gamification.challenge.line" id="line_associate_editor">
<field name="definition_id" eval="ref('definition_associate_editor')" />
<field name="target_goal">30</field>
<field name="challenge_id" eval="ref('challenge_associate_editor')" />
</record> -->
<!-- Enthusiast: vote for 15 days in a row -->
<record id="badge_9" model="gamification.badge">
<field name="name">Enthusiast</field>
<field name="description">Voted on questions/answers for 15 days in a row</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_enthusiast">
<field name="name">Enthusiast</field>
<field name="description">Vote on questions/answers for 15 days in a row</field>
<field name="computation_mode">python</field>
<field name="compute_code">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 &gt;= %s and create_date &lt;= %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)
</field>
<field name="display_mode">boolean</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_enthusiast">
<field name="name">Enthusiast</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_9')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_enthusiast">
<field name="definition_id" eval="ref('definition_enthusiast')"/>
<field name="challenge_id" eval="ref('challenge_enthusiast')"/>
<field name="target_goal">1</field>
</record>
<record id="badge_31" model="gamification.badge">
<field name="name">Supporter</field>
<field name="description">First upvote</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_supporter">
<field name="name">Supporter</field>
<field name="description">First upwnvote</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post_vote')" />
<field name="domain">[('user_id','=',user.id), ('vote', '=', '1')]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_supporter">
<field name="name">Supporter</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_31')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_supporter">
<field name="definition_id" eval="ref('definition_supporter')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_supporter')" />
</record>
<record id="badge_23" model="gamification.badge">
<field name="name">Peer Pressure</field>
<field name="description">Deleted own post with 3 or more downvotes</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_peer_pressure">
<field name="name">Peer Pressure</field>
<field name="description">Delete own post with 3 or more down votes</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id','=',user.id), ('vote_count', '&lt;=', -3), ('active', '=', False)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_peer_pressure">
<field name="name">Peer Pressure</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_23')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_peer_pressure">
<field name="definition_id" eval="ref('definition_peer_pressure')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_peer_pressure')" />
</record>
</data>
</openerp>

View File

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Biography: complet your profile -->
<record id="badge_p_1" model="gamification.badge">
<field name="name">Autobiographer</field>
<field name="description">Completed own biography</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_configure_profile">
<field name="name">Completed own biography</field>
<field name="description">Write some information about your self</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('base.model_res_users')" />
<field name="domain">[('id','=',user.id),
('partner_id.country_id', '!=', False),
('partner_id.city', '!=', False),
('partner_id.email', '!=', False)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_configure_profile">
<field name="name">Complete own biography</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_p_1')"/>
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_configure_profile">
<field name="definition_id" eval="ref('definition_configure_profile')"/>
<field name="challenge_id" eval="ref('challenge_configure_profile')"/>
<field name="target_goal">1</field>
</record>
<!-- Commentator: at least 10 comments posted on posts -->
<!-- <record id="badge_p_2" model="gamification.badge">
<field name="name">Commentator</field>
<field name="description">Posted 10 comments</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_commentator">
<field name="name">Commentator</field>
<field name="description">Comment an answer or a question</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('mail.model_mail_message')"/>
<field name="domain" eval="[('author_id', '=', user.partner_id.id), ('type', '=', 'comment'), ('subtype_id', '=', ref('mail.mt_comment')), ('model', '=', 'forum post')]"/>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_commentator">
<field name="name">Commentator</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_p_2')"/>
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_commentator">
<field name="definition_id" eval="ref('definition_commentator')"/>
<field name="challenge_id" eval="ref('challenge_commentator')"/>
<field name="target_goal">10</field>
</record> -->
<!-- Pundit: 10 comments with at least score of 10 -->
<!-- <record id="badge_25" model="gamification.badge">
<field name="name">Pundit</field>
<field name="description">Left 10 comments with score of 10 or more</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_pundit">
<field name="name">Pundit</field>
<field name="description">Post 10 comments with score of 10 or more</field>
<field name="computation_mode">python</field>
<field name="compute_code">def get_count(cr, uid, context=None):
res = 1
Message = self.pool['mail.message']
Post = self.pool['website.forum.post']
user_message = Message.read_group(cr, uid,[('create_uid','=',object.user_id.id), ('type', '=', 'comment'), ('model', '=', 'website.forum.post')], ['res_id'], groupby=['res_id'], context=context)
for rec in user_message:
if rec.get('res_id_count') >= 10:
post = Post.browse(cr, uid, rec.get('res_id'), context=context)
if post.vote_count >= 10:
res += 1
return res
result = get_count(cr, uid, context=context)
</field>
<field name="display_mode">boolean</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_pundit">
<field name="name">Pundit</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_25')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_pundit">
<field name="definition_id" eval="ref('definition_pundit')" />
<field name="target_goal">2</field>
<field name="challenge_id" eval="ref('challenge_pundit')" />
</record> -->
<!-- Chief Commentator: 100 comments -->
<!-- <record id="badge_p_4" model="gamification.badge">
<field name="name">Chief Commentator</field>
<field name="description">Posted 100 comments</field>
<field name="level">silver</field>
</record>
<record model="gamification.challenge" id="challenge_chief_commentator">
<field name="name">Commentator</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_p_4')"/>
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_chief_commentator">
<field name="definition_id" eval="ref('definition_commentator')"/>
<field name="challenge_id" eval="ref('challenge_chief_commentator')"/>
<field name="target_goal">100</field>
</record> -->
<!-- Expert: tag-based activity -->
<!-- <record id="badge_10" model="gamification.badge">
<field name="name">Expert</field>
<field name="description">Posted more than 10 questions or answers in one tag</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_expert">
<field name="name">Expert</field>
<field name="description">Post more than 10 questions in one tag</field>
<field name="computation_mode">python</field>
<field name="compute_code">def get_counter(cr, uid, context=None):
res = 1
Post = pool['forum.post']
Tag = pool['forum.tag']
for tag_id in Tag.search(cr, uid, [], context=context):
post_count = Post.search_count(cr, uid , [('tag_ids', 'in', tag_id), ('user_id', '=', object.user_id.id)], context=context)
if post_count >= 10:
res += 1
return res
result = get_counter(cr, uid, context=context)
</field>
<field name="display_mode">boolean</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_expert">
<field name="name">Expert</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_10')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_expert">
<field name="definition_id" eval="ref('definition_expert')" />
<field name="target_goal">2</field>
<field name="challenge_id" eval="ref('challenge_expert')" />
</record> -->
<!-- <record id="badge_32" model="gamification.badge">
<field name="name">Taxonomist</field>
<field name="description">Created a tag used by 15 questions</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_taxonomist">
<field name="name">Taxonomist</field>
<field name="description">Create a tag which can used in minimum 15 questions</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_website_forum_tag')" />
<field name="domain">[('create_uid','=',user.id), ('posts_count', '>=', 15)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_taxonomist">
<field name="name">Taxonomist</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_32')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_taxonomist">
<field name="definition_id" eval="ref('definition_taxonomist')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_taxonomist')" />
</record> -->
</data>
</openerp>

View File

@ -0,0 +1,343 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- POPULARITY (VIEWS) -->
<!-- Popular: 150 views -->
<record id="badge_q_1" model="gamification.badge">
<field name="name">Popular Question</field>
<field name="description">Asked a question with at least 150 views</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_popular_question">
<field name="name">Popular Question</field>
<field name="description">Asked a question with at least 150 views</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 150)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_popular_question">
<field name="name">Popular Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_1')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_popular_question">
<field name="definition_id" eval="ref('definition_popular_question')"/>
<field name="challenge_id" eval="ref('challenge_popular_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Notable: 250 views -->
<record id="badge_q_2" model="gamification.badge">
<field name="name">Notable Question</field>
<field name="description">Asked a question with at least 250 views</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_notable_question">
<field name="name">Notable Question</field>
<field name="description">Asked a question with at least 250 views</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 250)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_notable_question">
<field name="name">Notable Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_2')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_notable_question">
<field name="definition_id" eval="ref('definition_notable_question')"/>
<field name="challenge_id" eval="ref('challenge_notable_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Famous: 500 views -->
<record id="badge_q_3" model="gamification.badge">
<field name="name">Famous Question</field>
<field name="description">Asked a question with at least 500 views</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_famous_question">
<field name="name">Famous Question</field>
<field name="description">Asked a question with at least 500 views</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('views', '>=', 500)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_famous_question">
<field name="name">Famous Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_3')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_famous_question">
<field name="definition_id" eval="ref('definition_famous_question')"/>
<field name="challenge_id" eval="ref('challenge_famous_question')"/>
<field name="target_goal">1</field>
</record>
<!-- FAVORITE -->
<!-- Credible: at least 1 user have it in favorite -->
<record id="badge_q_4" model="gamification.badge">
<field name="name">Credible Question</field>
<field name="description">Question set as favorite by 1 user1</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_favorite_question">
<field name="name">Credible Question</field>
<field name="description">Question set as favorite by 1 user</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 1)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_favorite_question">
<field name="name">Credible Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_4')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_favorite_question">
<field name="definition_id" eval="ref('definition_favorite_question')"/>
<field name="challenge_id" eval="ref('challenge_favorite_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Favorite: at least 5 users have it in favorite -->
<record id="badge_q_5" model="gamification.badge">
<field name="name">Favorite Question</field>
<field name="description">Question set as favorite by 5 users</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_favorite_question">
<field name="name">Favorite Question</field>
<field name="description">Question set as favorite by 5 users</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 5)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_favorite_question">
<field name="name">Favorite Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_5')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_favorite_question">
<field name="definition_id" eval="ref('definition_favorite_question')"/>
<field name="challenge_id" eval="ref('challenge_favorite_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Stellar: at least 25 users have it in favorite -->
<record id="badge_q_6" model="gamification.badge">
<field name="name">Stellar Question</field>
<field name="description">Question set as favorite by 5 users</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_stellar_question">
<field name="name">Stellar Question</field>
<field name="description">Question set as favorite by 5 users</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('create_uid', '=', user.id), ('parent_id', '=', False), ('favorite_count', '>=', 25)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_stellar_question">
<field name="name">Stellar Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_6')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_stellar_question">
<field name="definition_id" eval="ref('definition_stellar_question')"/>
<field name="challenge_id" eval="ref('challenge_stellar_question')"/>
<field name="target_goal">1</field>
</record>
<!-- QUALITY (VOTES) -->
<!-- Student: at least 1 upvote -->
<record id="badge_q_7" model="gamification.badge">
<field name="name">Student</field>
<field name="description">Asked first question with at least one up vote</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_student">
<field name="name">Student</field>
<field name="description">Asked first question with at least one up vote</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 1)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_student">
<field name="name">Student</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_7')"/>
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_student">
<field name="definition_id" eval="ref('definition_student')"/>
<field name="challenge_id" eval="ref('challenge_student')"/>
<field name="target_goal">1</field>
</record>
<!-- Nice: at least 4 upvotes -->
<record id="badge_q_8" model="gamification.badge">
<field name="name">Nice Quesiotn</field>
<field name="description">Question voted up 4 times</field>
<field name="level">bronze</field>
</record>
<record model="gamification.goal.definition" id="definition_nice_question">
<field name="name">Nice Question</field>
<field name="description">Question voted up 4 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')"/>
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 4)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_nice_question">
<field name="name">Nice Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_8')" />
<field name="autojoin_group_id" eval="ref('base.group_user')"/>
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_nice_question">
<field name="definition_id" eval="ref('definition_nice_question')"/>
<field name="challenge_id" eval="ref('challenge_nice_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Good: at least 6 upvotes -->
<record id="badge_q_9" model="gamification.badge">
<field name="name">Good Question</field>
<field name="description">Question voted up 6 times</field>
<field name="level">silver</field>
</record>
<record model="gamification.goal.definition" id="definition_good_question">
<field name="name">Good Question</field>
<field name="description">Question voted up 6 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id', '=', user.id), ('parent_id', '=', False), ('vote_count', '>=', 6)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_good_question">
<field name="name">Good Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_9')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_good_question">
<field name="definition_id" eval="ref('definition_good_question')"/>
<field name="challenge_id" eval="ref('challenge_good_question')"/>
<field name="target_goal">1</field>
</record>
<!-- Great: at least 15 upvotes -->
<record id="badge_q_10" model="gamification.badge">
<field name="name">Great Question</field>
<field name="description">Question voted up 15 times</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_great_question">
<field name="name">Great Question</field>
<field name="description">Question voted up 15 times</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('vote_count', '>=', 15)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_great_question">
<field name="name">Great Question</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_q_10')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_great_question">
<field name="definition_id" eval="ref('definition_great_question')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_great_question')" />
</record>
<!-- Question + Answer -->
<!-- <record id="badge_26" model="gamification.badge">
<field name="name">Scholar</field>
<field name="description">Asked a question and accepted an answer</field>
<field name="level">gold</field>
</record>
<record model="gamification.goal.definition" id="definition_scholar">
<field name="name">Scholar</field>
<field name="description">Ask a question and accept an answer</field>
<field name="computation_mode">count</field>
<field name="display_mode">boolean</field>
<field name="model_id" eval="ref('website_forum.model_forum_post')" />
<field name="domain">[('user_id','=',user.id), ('parent_id', '=', False), ('is_correct', '=', True)]</field>
<field name="condition">higher</field>
</record>
<record model="gamification.challenge" id="challenge_scholar">
<field name="name">Scholar</field>
<field name="period">once</field>
<field name="visibility_mode">personal</field>
<field name="report_message_frequency">never</field>
<field name="reward_id" eval="ref('badge_26')" />
<field name="autojoin_group_id" eval="ref('base.group_user')" />
<field name="state">inprogress</field>
<field name="category">forum</field>
</record>
<record model="gamification.challenge.line" id="line_scholar">
<field name="definition_id" eval="ref('definition_scholar')" />
<field name="target_goal">1</field>
<field name="challenge_id" eval="ref('challenge_scholar')" />
</record> -->
</data>
</openerp>