#2239 disallow pools literally named series/collection

This commit is contained in:
Toks
2015-05-02 12:09:11 -04:00
parent 5a8674d342
commit b7a001c6d4

View File

@@ -5,6 +5,7 @@ class Pool < ActiveRecord::Base
validates_format_of :name, :with => /\A[^,]+\Z/, :message => "cannot have commas"
validates_inclusion_of :category, :in => %w(series collection)
validate :updater_can_change_category
validate :name_does_not_conflict_with_metatags
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :versions, lambda {order("pool_versions.id ASC")}, :class_name => "PoolVersion", :dependent => :destroy
@@ -405,4 +406,13 @@ class Pool < ActiveRecord::Base
true
end
end
def name_does_not_conflict_with_metatags
if %w(any none series collection).include?(name.downcase.tr(" ", "_"))
errors[:base] << "Pools cannot have the following names: any, none, series, collection"
false
else
true
end
end
end