mirror of
https://github.com/meineerde/redmine.git
synced 2026-04-03 14:31:38 +00:00
Use .unscoped when querying and creating builtin objects (#24156).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@16049 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e8c17ac6d7
commit
3e86a2ab52
@ -37,12 +37,12 @@ class GroupBuiltin < Group
|
|||||||
class << self
|
class << self
|
||||||
def load_instance
|
def load_instance
|
||||||
return nil if self == GroupBuiltin
|
return nil if self == GroupBuiltin
|
||||||
instance = order('id').first || create_instance
|
instance = unscoped.order('id').first || create_instance
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_instance
|
def create_instance
|
||||||
raise 'The builtin group already exists.' if exists?
|
raise 'The builtin group already exists.' if exists?
|
||||||
instance = new
|
instance = unscoped.new
|
||||||
instance.lastname = name
|
instance.lastname = name
|
||||||
instance.save :validate => false
|
instance.save :validate => false
|
||||||
raise 'Unable to create builtin group.' if instance.new_record?
|
raise 'Unable to create builtin group.' if instance.new_record?
|
||||||
|
|||||||
@ -294,9 +294,9 @@ private
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.find_or_create_system_role(builtin, name)
|
def self.find_or_create_system_role(builtin, name)
|
||||||
role = where(:builtin => builtin).first
|
role = unscoped.where(:builtin => builtin).first
|
||||||
if role.nil?
|
if role.nil?
|
||||||
role = create(:name => name) do |r|
|
role = unscoped.create(:name => name) do |r|
|
||||||
r.builtin = builtin
|
r.builtin = builtin
|
||||||
end
|
end
|
||||||
raise "Unable to create the #{name} role (#{role.errors.full_messages.join(',')})." if role.new_record?
|
raise "Unable to create the #{name} role (#{role.errors.full_messages.join(',')})." if role.new_record?
|
||||||
|
|||||||
@ -750,9 +750,9 @@ class User < Principal
|
|||||||
# Returns the anonymous user. If the anonymous user does not exist, it is created. There can be only
|
# Returns the anonymous user. If the anonymous user does not exist, it is created. There can be only
|
||||||
# one anonymous user per database.
|
# one anonymous user per database.
|
||||||
def self.anonymous
|
def self.anonymous
|
||||||
anonymous_user = AnonymousUser.first
|
anonymous_user = AnonymousUser.unscoped.first
|
||||||
if anonymous_user.nil?
|
if anonymous_user.nil?
|
||||||
anonymous_user = AnonymousUser.create(:lastname => 'Anonymous', :firstname => '', :login => '', :status => 0)
|
anonymous_user = AnonymousUser.unscoped.create(:lastname => 'Anonymous', :firstname => '', :login => '', :status => 0)
|
||||||
raise 'Unable to create the anonymous user.' if anonymous_user.new_record?
|
raise 'Unable to create the anonymous user.' if anonymous_user.new_record?
|
||||||
end
|
end
|
||||||
anonymous_user
|
anonymous_user
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user