pools: cleanup unneeded code.
* create_mod_action_for_destroy didn't exist (pools are never destroyed). * is_active and is_deleted are already initialized via database defaults. * creator_name is already defined by belongs_to_creator. * Returning true/false in validations does nothing.
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
require 'ostruct'
|
|
||||||
|
|
||||||
class Pool < ApplicationRecord
|
class Pool < ApplicationRecord
|
||||||
class RevertError < Exception ; end
|
class RevertError < Exception ; end
|
||||||
|
|
||||||
@@ -12,11 +10,9 @@ class Pool < ApplicationRecord
|
|||||||
belongs_to_creator
|
belongs_to_creator
|
||||||
before_validation :normalize_post_ids
|
before_validation :normalize_post_ids
|
||||||
before_validation :normalize_name
|
before_validation :normalize_name
|
||||||
before_validation :initialize_is_active, :on => :create
|
|
||||||
after_save :update_category_pseudo_tags_for_posts_async
|
after_save :update_category_pseudo_tags_for_posts_async
|
||||||
after_save :create_version
|
after_save :create_version
|
||||||
after_create :synchronize!
|
after_create :synchronize!
|
||||||
before_destroy :create_mod_action_for_destroy
|
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def deleted
|
def deleted
|
||||||
@@ -149,11 +145,6 @@ class Pool < ApplicationRecord
|
|||||||
category == "collection"
|
category == "collection"
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize_is_active
|
|
||||||
self.is_deleted = false if is_deleted.nil?
|
|
||||||
self.is_active = true if is_active.nil?
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalize_name
|
def normalize_name
|
||||||
self.name = Pool.normalize_name(name)
|
self.name = Pool.normalize_name(name)
|
||||||
end
|
end
|
||||||
@@ -166,10 +157,6 @@ class Pool < ApplicationRecord
|
|||||||
category.titleize
|
category.titleize
|
||||||
end
|
end
|
||||||
|
|
||||||
def creator_name
|
|
||||||
User.id_to_name(creator_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalize_post_ids
|
def normalize_post_ids
|
||||||
self.post_ids = self.class.normalize_post_ids(post_ids, is_collection?)
|
self.post_ids = self.class.normalize_post_ids(post_ids, is_collection?)
|
||||||
end
|
end
|
||||||
@@ -200,9 +187,6 @@ class Pool < ApplicationRecord
|
|||||||
def updater_can_edit_deleted
|
def updater_can_edit_deleted
|
||||||
if is_deleted? && !deletable_by?(CurrentUser.user)
|
if is_deleted? && !deletable_by?(CurrentUser.user)
|
||||||
errors[:base] << "You cannot update pools that are deleted"
|
errors[:base] << "You cannot update pools that are deleted"
|
||||||
false
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -375,9 +359,6 @@ class Pool < ApplicationRecord
|
|||||||
def updater_can_change_category
|
def updater_can_change_category
|
||||||
if category_changed? && !category_changeable_by?(CurrentUser.user)
|
if category_changed? && !category_changeable_by?(CurrentUser.user)
|
||||||
errors[:base] << "You cannot change the category of pools with greater than #{Danbooru.config.pool_category_change_limit} posts"
|
errors[:base] << "You cannot change the category of pools with greater than #{Danbooru.config.pool_category_change_limit} posts"
|
||||||
false
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -400,9 +381,6 @@ class Pool < ApplicationRecord
|
|||||||
removed = post_id_array_was - post_id_array
|
removed = post_id_array_was - post_id_array
|
||||||
if removed.any? && !CurrentUser.user.can_remove_from_pools?
|
if removed.any? && !CurrentUser.user.can_remove_from_pools?
|
||||||
errors[:base] << "You cannot removes posts from pools within the first week of sign up"
|
errors[:base] << "You cannot removes posts from pools within the first week of sign up"
|
||||||
false
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user