Skip to content

Commit

Permalink
Remove the last few references to has_role?(:admin)
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Oct 31, 2020
1 parent 33d9e01 commit 2dc323e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/models/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Block < ApplicationRecord
validate :not_blocking_admin
def not_blocking_admin
return unless blocked
errors.add(:blocked, 'You cannot block admins.') if blocked.has_role?(:admin)
errors.add(:blocked, 'You cannot block moderators.') if blocked.title == 'Mod'
errors.add(:blocked, 'You cannot block admins.') if blocked.permissions.admin?
errors.add(:blocked, 'You cannot block moderators.') if blocked.permissions.community_mod?
end

validate :not_blocking_self
Expand Down
2 changes: 1 addition & 1 deletion app/models/library_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LibraryEntry < ApplicationRecord
scope = user && !user.sfw_filter? ? all : sfw

return scope.privacy(:public) unless user
return scope if user.has_role?(:admin)
return scope if user.permissions.admin?

scope.privacy(:public).or(
where(user_id: user).privacy(:private)
Expand Down
8 changes: 4 additions & 4 deletions config/initializers/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
end

Flipper.register(:staff) do |user|
user.try(:has_role?, :admin)
user&.permissions&.admin?
end

Flipper.register(:pro) do |user|
user.try(:pro?)
user&.pro?
end

Flipper.register(:mod) do |user|
user.try(:has_role?, :mod) || user.try(:has_role?, :admin, Anime)
user&.permissions&.community_mod? || user&.permissions&.database_mod?
end

Flipper.register(:aozora) do |user|
user.try(:ao_id)
user&.ao_id
end

0 comments on commit 2dc323e

Please sign in to comment.