Merge pull request #589 from goshakkk/user-admin-scope

Create the User.admins and User.moderators scopes
This commit is contained in:
Robin Ward
2013-03-29 10:06:28 -07:00
5 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ class AdminConstraint
def matches?(request)
return false unless request.session[:current_user_id].present?
User.where(id: request.session[:current_user_id].to_i).where(admin: true).exists?
User.admins.where(id: request.session[:current_user_id].to_i).exists?
end
end
end
+1 -1
View File
@@ -41,7 +41,7 @@ class SystemMessage
# Either returns the system_username user or the first admin.
def self.system_user
user = User.where(username_lower: SiteSetting.system_username).first if SiteSetting.system_username.present?
user = User.where(admin: true).order(:id).first if user.blank?
user = User.admins.order(:id).first if user.blank?
user
end