<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="1">

        <!-- Cleanup: answer or question edition -->
        <!-- Not rollback feature in forum -->
<!--         <record id="badge_3" model="gamification.badge">
            <field name="name">Cleanup</field>
            <field name="description">First rollback</field>
            <field name="level">gold</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>
            <field name="rule_auth">nobody</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="condition">higher</field>
            <field name="domain">[('vote', '=', '-1')]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_vote_user_id')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <field name="user_domain">[('karma', '>', 0)]</field>
            <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>
            <field name="rule_auth">nobody</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="condition">higher</field>
            <field name="domain">[('vote_count', '>=', 3), ('active', '=', False)]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_create_uid')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <field name="user_domain">[('karma', '>', 0)]</field>
            <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>
            <field name="rule_auth">nobody</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="condition">higher</field>
            <field name="domain" eval="[('model', '=', 'forum.post'), ('subtype_id', 'in', [ref('website_forum.mt_answer_edit'), ref('website_forum.mt_question_edit')])]"/>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('mail.field_mail_message_author_id')" />
            <field name="batch_user_expression">user.partner_id.id</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="reward_realtime">True</field>
            <field name="user_domain">[('karma', '>', 0)]</field>
            <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="condition">higher</field>
            <field name="domain">[('tags','!=',False)]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_create_uid')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <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="condition">higher</field>
            <field name="domain">['|', ('name','!=',False), ('content','!=',False)]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_create_uid')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <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>
            <field name="rule_auth">nobody</field>
        </record>
        <record model="gamification.goal.definition" id="definition_supporter">
            <field name="name">Supporter</field>
            <field name="description">First upvote</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="condition">higher</field>
            <field name="domain">[('vote', '=', '1')]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_vote_user_id')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <field name="user_domain">[('karma', '>', 0)]</field>
            <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>
            <field name="rule_auth">nobody</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="condition">higher</field>
            <field name="domain">[('vote_count', '&lt;=', -3), ('active', '=', False)]</field>
            <field name="batch_mode">True</field>
            <field name="batch_distinctive_field" eval="ref('website_forum.field_forum_post_create_uid')" />
            <field name="batch_user_expression">user.id</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="reward_realtime">True</field>
            <field name="user_domain">[('karma', '>', 0)]</field>
            <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>