From d82628987a3d710e647fb9e490a251e642463358 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Mon, 21 Jan 2019 19:21:55 +0100 Subject: [PATCH] FIX: Badges appeared in wrong badge group Some badges always appeared in the "Other" group (the default group) and some badges were always moved back into the original group during seeding. Now badges are either in the correct, seeded group or stay in a custom group if the admin moved the badge into a custom group. --- app/models/badge.rb | 2 +- db/fixtures/006_badges.rb | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/models/badge.rb b/app/models/badge.rb index 117f27c5836..33b5426edfa 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -199,7 +199,7 @@ class Badge < ActiveRecord::Base def default_badge_grouping_id=(val) # allow to correct orphans - if !self.badge_grouping_id || self.badge_grouping_id < 0 + if !self.badge_grouping_id || self.badge_grouping_id <= BadgeGrouping::Other self.badge_grouping_id = val end end diff --git a/db/fixtures/006_badges.rb b/db/fixtures/006_badges.rb index 6008cd93e8e..12c189da111 100644 --- a/db/fixtures/006_badges.rb +++ b/db/fixtures/006_badges.rb @@ -55,7 +55,7 @@ SQL b.default_badge_grouping_id = BadgeGrouping::TrustLevel b.trigger = Badge::Trigger::TrustLevelChange # allow title for tl3 and above - b.default_allow_title = id > 2 + b.default_allow_title = id > Badge::Member b.default_icon = "fa-user" b.system = true end @@ -134,7 +134,6 @@ Badge.seed do |b| b.target_posts = true b.show_posts = false b.query = BadgeQueries::FirstFlag - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::PostAction b.auto_revoke = false @@ -227,7 +226,6 @@ Badge.seed do |b| b.badge_type_id = BadgeType::Bronze b.multiple_grant = false b.query = BadgeQueries::Editor - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::PostRevision b.system = true @@ -240,7 +238,6 @@ Badge.seed do |b| b.multiple_grant = false b.target_posts = true b.query = BadgeQueries::WikiEditor - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::PostRevision b.system = true @@ -294,7 +291,6 @@ end b.target_posts = true b.show_posts = true b.query = BadgeQueries.linking_badge(count) - b.badge_grouping_id = BadgeGrouping::Posting b.default_badge_grouping_id = BadgeGrouping::Posting # don't trigger for now, its too expensive b.trigger = Badge::Trigger::None @@ -331,7 +327,6 @@ end b.default_icon = "fa-heart" b.badge_type_id = level b.query = BadgeQueries.liked_back(count, ratio) - b.badge_grouping_id = BadgeGrouping::Community b.default_badge_grouping_id = BadgeGrouping::Community b.trigger = Badge::Trigger::None b.auto_revoke = false @@ -350,7 +345,6 @@ end b.default_icon = "fa-heart" b.badge_type_id = level b.query = BadgeQueries.like_rate_limit(count) - b.badge_grouping_id = BadgeGrouping::Community b.default_badge_grouping_id = BadgeGrouping::Community b.trigger = Badge::Trigger::None b.auto_revoke = false @@ -366,7 +360,6 @@ Badge.seed do |b| b.target_posts = true b.show_posts = true b.query = BadgeQueries::FirstMention - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::PostRevision b.system = true @@ -380,7 +373,6 @@ Badge.seed do |b| b.target_posts = true b.show_posts = true b.query = nil - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::None b.system = true @@ -394,7 +386,6 @@ Badge.seed do |b| b.target_posts = true b.show_posts = true b.query = nil - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::None b.system = true @@ -408,7 +399,6 @@ Badge.seed do |b| b.target_posts = true b.show_posts = true b.query = nil - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::None b.system = true @@ -422,7 +412,6 @@ Badge.seed do |b| b.target_posts = false b.show_posts = false b.query = nil - b.badge_grouping_id = BadgeGrouping::GettingStarted b.default_badge_grouping_id = BadgeGrouping::GettingStarted b.trigger = Badge::Trigger::None b.system = true @@ -439,7 +428,6 @@ end b.default_icon = "fa-eye" b.badge_type_id = level b.query = BadgeQueries.consecutive_visits(days) - b.badge_grouping_id = BadgeGrouping::Community b.default_badge_grouping_id = BadgeGrouping::Community b.trigger = Badge::Trigger::None b.auto_revoke = false