add `admin?` shorthand to users

This commit is contained in:
Andreas Nedbal 2022-08-21 15:02:49 +02:00
parent ffc0ba05e1
commit 56a1c70fae
1 changed files with 4 additions and 0 deletions

View File

@ -141,6 +141,10 @@ class User < ApplicationRecord
has_role?(:moderator) || has_role?(:administrator) has_role?(:moderator) || has_role?(:administrator)
end end
def admin?
has_role?(:administrator)
end
# region stuff used for reporting/moderation # region stuff used for reporting/moderation
def report(object, reason = nil) def report(object, reason = nil)
existing = Report.find_by(type: "Reports::#{object.class}", target_id: object.id, user_id: self.id, deleted: false) existing = Report.find_by(type: "Reports::#{object.class}", target_id: object.id, user_id: self.id, deleted: false)