pools: allow new users to remove posts from pools.
Remove the rule that users less than a week old can't remove posts from pools.
This commit is contained in:
@@ -7,7 +7,6 @@ class Pool < ApplicationRecord
|
|||||||
validates_uniqueness_of :name, case_sensitive: false, if: :name_changed?
|
validates_uniqueness_of :name, case_sensitive: false, if: :name_changed?
|
||||||
validate :validate_name, if: :name_changed?
|
validate :validate_name, if: :name_changed?
|
||||||
validates_inclusion_of :category, :in => %w(series collection)
|
validates_inclusion_of :category, :in => %w(series collection)
|
||||||
validate :updater_can_remove_posts
|
|
||||||
validate :updater_can_edit_deleted
|
validate :updater_can_edit_deleted
|
||||||
before_validation :normalize_post_ids
|
before_validation :normalize_post_ids
|
||||||
before_validation :normalize_name
|
before_validation :normalize_name
|
||||||
@@ -173,7 +172,6 @@ class Pool < ApplicationRecord
|
|||||||
|
|
||||||
def remove!(post)
|
def remove!(post)
|
||||||
return unless contains?(post.id)
|
return unless contains?(post.id)
|
||||||
return unless CurrentUser.user.can_remove_from_pools?
|
|
||||||
|
|
||||||
with_lock do
|
with_lock do
|
||||||
reload
|
reload
|
||||||
@@ -276,11 +274,4 @@ class Pool < ApplicationRecord
|
|||||||
errors[:name] << "cannot contain only digits"
|
errors[:name] << "cannot contain only digits"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def updater_can_remove_posts
|
|
||||||
removed = post_ids_was - post_ids
|
|
||||||
if removed.any? && !CurrentUser.user.can_remove_from_pools?
|
|
||||||
errors[:base] << "You cannot removes posts from pools within the first week of sign up"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1011,7 +1011,6 @@ class Post < ApplicationRecord
|
|||||||
|
|
||||||
def remove_pool!(pool)
|
def remove_pool!(pool)
|
||||||
return unless belongs_to_pool?(pool)
|
return unless belongs_to_pool?(pool)
|
||||||
return unless CurrentUser.user.can_remove_from_pools?
|
|
||||||
|
|
||||||
with_lock do
|
with_lock do
|
||||||
self.pool_string = pool_string.gsub(/(?:\A| )pool:#{pool.id}(?:\Z| )/, " ").strip
|
self.pool_string = pool_string.gsub(/(?:\A| )pool:#{pool.id}(?:\Z| )/, " ").strip
|
||||||
|
|||||||
@@ -414,10 +414,6 @@ class User < ApplicationRecord
|
|||||||
CommentVote.where("user_id = ? and created_at > ?", id, 1.hour.ago).count < 10
|
CommentVote.where("user_id = ? and created_at > ?", id, 1.hour.ago).count < 10
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_remove_from_pools?
|
|
||||||
created_at <= 1.week.ago
|
|
||||||
end
|
|
||||||
|
|
||||||
def upload_limit
|
def upload_limit
|
||||||
@upload_limit ||= UploadLimit.new(self)
|
@upload_limit ||= UploadLimit.new(self)
|
||||||
end
|
end
|
||||||
@@ -509,7 +505,7 @@ class User < ApplicationRecord
|
|||||||
custom_style favorite_count api_regen_multiplier
|
custom_style favorite_count api_regen_multiplier
|
||||||
api_burst_limit remaining_api_limit statement_timeout
|
api_burst_limit remaining_api_limit statement_timeout
|
||||||
favorite_group_limit favorite_limit tag_query_limit
|
favorite_group_limit favorite_limit tag_query_limit
|
||||||
can_remove_from_pools? is_comment_limited?
|
is_comment_limited?
|
||||||
can_comment? max_saved_searches theme
|
can_comment? max_saved_searches theme
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user