DEV: Reuse code for TrustLevelAndStaffSetting (#15044)

The code that checked this permission was duplicated everytime a new
settings of this type was added. This commit changes the behavior of
some functionality because some feature checks were bypassed for staff
members.
This commit is contained in:
Dan Ungureanu
2021-11-22 20:18:53 +02:00
committed by GitHub
parent fd66df5997
commit d420a7b2c8
4 changed files with 13 additions and 13 deletions

View File

@ -1021,6 +1021,12 @@ class User < ActiveRecord::Base
admin? || moderator? || staged? || TrustLevel.compare(trust_level, level)
end
def has_trust_level_or_staff?(level)
return admin? if level.to_s == 'admin'
return staff? if level.to_s == 'staff'
has_trust_level?(level.to_i)
end
# a touch faster than automatic
def admin?
admin