gamification_plugin.rb
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class GamificationPlugin < Noosfero::Plugin
def self.plugin_name
"Gamification Plugin"
end
def self.plugin_description
_("Gamification Plugin")
end
def user_data_extras
proc do
{:points => current_person.points}
end
end
# Override initial rules with environment specific rules
def self.gamification_set_rules(environment)
Merit::AppPointRules.clear
Merit::AppBadgeRules.clear
Merit::AppPointRules.merge!(Merit::PointRules.new(environment).defined_rules)
Merit::AppBadgeRules.merge!(Merit::BadgeRules.new(environment).defined_rules)
end
def application_controller_filters
[{
:type => 'before_filter', :method_name => 'gamification_set_rules',
:options => {}, :block => proc { GamificationPlugin.gamification_set_rules(environment) }
}]
end
def body_ending
proc { render :file => 'gamification/display_achievements' }
end
ActionDispatch::Reloader.to_prepare do
Merit.setup do |config|
config.checks_on_each_request = false
config.user_model_name = 'Profile'
config.current_user_method = 'current_person'
end
require_dependency 'merit_ext'
end
end