From 007310c4a252611f1594da36a5b9c542b335bedf Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 22 Jul 2014 12:46:31 +1000 Subject: [PATCH] Wire up triggers --- app/models/badge.rb | 6 ++++-- app/models/badge_grouping.rb | 2 +- db/fixtures/006_badges.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/models/badge.rb b/app/models/badge.rb index 35ac8c57c..db24b720a 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -17,11 +17,12 @@ class Badge < ActiveRecord::Base # other consts AutobiographerMinBioLength = 10 - module Triggers + module Trigger PostAction = 1 ReadGuidelines = 2 PostRevision = 4 TrustLevelChange = 8 + UserChange = 16 end module Queries @@ -213,7 +214,8 @@ end # query :text # enabled :boolean default(TRUE), not null # auto_revoke :boolean default(TRUE), not null -# badge_grouping_id :integer +# badge_grouping_id :integer default(5), not null +# trigger :integer # # Indexes # diff --git a/app/models/badge_grouping.rb b/app/models/badge_grouping.rb index 066bd7933..88d96fd6e 100644 --- a/app/models/badge_grouping.rb +++ b/app/models/badge_grouping.rb @@ -15,7 +15,7 @@ end # # id :integer not null, primary key # name :string(255) not null -# description :string(255) not null +# description :text # position :integer not null # created_at :datetime # updated_at :datetime diff --git a/db/fixtures/006_badges.rb b/db/fixtures/006_badges.rb index 4f4fae2ff..ac37ad4b3 100644 --- a/db/fixtures/006_badges.rb +++ b/db/fixtures/006_badges.rb @@ -52,6 +52,7 @@ trust_level_badges.each do |spec| b.badge_type_id = spec[:type] b.query = Badge::Queries.trust_level(spec[:id]) b.default_badge_grouping_id = BadgeGrouping::TrustLevel + b.trigger = Badge::Trigger::TrustLevelChange # allow title for leader and elder b.allow_title = spec[:id] > 2 @@ -77,6 +78,7 @@ Badge.seed do |b| b.target_posts = false b.query = Badge::Queries::ReadGuidelines b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::ReadGuidelines end Badge.seed do |b| @@ -87,6 +89,7 @@ Badge.seed do |b| b.target_posts = true b.query = Badge::Queries::FirstLink b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::PostRevision end Badge.seed do |b| @@ -97,6 +100,7 @@ Badge.seed do |b| b.target_posts = true b.query = Badge::Queries::FirstQuote b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::PostRevision end Badge.seed do |b| @@ -107,6 +111,7 @@ Badge.seed do |b| b.target_posts = true b.query = Badge::Queries::FirstLike b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::PostAction end Badge.seed do |b| @@ -117,6 +122,7 @@ Badge.seed do |b| b.target_posts = false b.query = Badge::Queries::FirstFlag b.default_badge_grouping_id = BadgeGrouping::Community + b.trigger = Badge::Trigger::PostAction end Badge.seed do |b| @@ -127,6 +133,7 @@ Badge.seed do |b| b.target_posts = true b.query = Badge::Queries::FirstShare b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::PostRevision end Badge.seed do |b| @@ -137,6 +144,7 @@ Badge.seed do |b| b.target_posts = true b.query = Badge::Queries::Welcome b.default_badge_grouping_id = BadgeGrouping::Community + b.trigger = Badge::Trigger::PostAction end Badge.seed do |b| @@ -146,6 +154,7 @@ Badge.seed do |b| b.multiple_grant = false b.query = Badge::Queries::Autobiographer b.default_badge_grouping_id = BadgeGrouping::GettingStarted + b.trigger = Badge::Trigger::UserChange end Badge.seed do |b| @@ -155,6 +164,7 @@ Badge.seed do |b| b.multiple_grant = false b.query = Badge::Queries::Editor b.default_badge_grouping_id = BadgeGrouping::Community + b.trigger = Badge::Trigger::PostRevision end # @@ -174,5 +184,6 @@ like_badges.each do |spec| b.target_posts = true b.query = Badge::Queries.like_badge(Badge.like_badge_counts[spec[:id]]) b.default_badge_grouping_id = BadgeGrouping::Posting + b.trigger = Badge::Trigger::PostAction end end