Fixed owner links in projects & groups
This commit is contained in:
parent
5fb704d3c5
commit
b48e4af930
|
@ -28,7 +28,9 @@ class Group < ActiveRecord::Base
|
|||
include PersonalRepository
|
||||
|
||||
before_create :add_default_role
|
||||
before_save :add_owner_rel
|
||||
#before_save :add_owner_rel
|
||||
after_create :make_owner_rel
|
||||
before_save :check_owner_rel
|
||||
|
||||
def roles_of(user)
|
||||
objects.where(:object_id => user.id, :object_type => user.class).map {|rel| rel.role}.reject {|r| r.nil?}
|
||||
|
@ -55,4 +57,15 @@ class Group < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def make_owner_rel
|
||||
add_owner owner
|
||||
end
|
||||
|
||||
def check_owner_rel
|
||||
if !new_record? and owner_id_changed?
|
||||
remove_owner owner_type_was.classify.find(owner_id_was) if owner_type_was
|
||||
add_owner owner if owner
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -31,7 +31,10 @@ class Project < ActiveRecord::Base
|
|||
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") }
|
||||
scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)")
|
||||
|
||||
before_save :add_owner_rel
|
||||
# before_save :add_owner_rel
|
||||
after_create :make_owner_rel
|
||||
before_save :check_owner_rel
|
||||
|
||||
after_create :attach_to_personal_repository
|
||||
after_create :create_git_repo
|
||||
before_update :update_git_repo
|
||||
|
@ -153,4 +156,16 @@ class Project < ActiveRecord::Base
|
|||
add_owner owner
|
||||
end
|
||||
end
|
||||
|
||||
def make_owner_rel
|
||||
add_owner owner
|
||||
end
|
||||
|
||||
def check_owner_rel
|
||||
if !new_record? and owner_id_changed?
|
||||
remove_owner owner_type_was.classify.find(owner_id_was) if owner_type_was
|
||||
add_owner owner if owner
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ class Repository < ActiveRecord::Base
|
|||
#before_save :create_directory
|
||||
#before_save :add_owner_rel
|
||||
#after_destroy :remove_directory
|
||||
|
||||
before_create :xml_rpc_create
|
||||
before_destroy :xml_rpc_destroy
|
||||
|
||||
|
|
Loading…
Reference in New Issue