FIX: system badges where created under id 100

This commit is contained in:
Sam
2014-08-06 10:51:39 +10:00
parent 70b5dfc4fa
commit 0b01310c84
5 changed files with 39 additions and 5 deletions

View File

@ -176,6 +176,8 @@ SQL
scope :enabled, ->{ where(enabled: true) }
before_create :ensure_not_system
# fields that can not be edited on system badges
def self.protected_system_fields
[:badge_type_id, :multiple_grant, :target_posts, :show_posts, :query, :trigger, :auto_revoke, :listable]
@ -203,10 +205,6 @@ SQL
!self.multiple_grant?
end
def system?
id && id < 100
end
def default_name=(val)
self.name ||= val
end
@ -221,6 +219,13 @@ SQL
self.badge_grouping_id = val
end
end
protected
def ensure_not_system
unless id
self.id = [Badge.maximum(:id) + 1, 100].max
end
end
end
# == Schema Information