|
|
@@ -319,6 +319,7 @@ class Project < ActiveRecord::Base |
|
|
|
if args.first && args.first.is_a?(String) && !/^\d*$/.match?(args.first) |
|
|
|
project = find_by_identifier(*args) |
|
|
|
raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil? |
|
|
|
|
|
|
|
project |
|
|
|
else |
|
|
|
super |
|
|
@@ -386,6 +387,7 @@ class Project < ActiveRecord::Base |
|
|
|
exists? |
|
|
|
return false |
|
|
|
end |
|
|
|
|
|
|
|
Project.transaction do |
|
|
|
archive! |
|
|
|
end |
|
|
@@ -411,6 +413,7 @@ class Project < ActiveRecord::Base |
|
|
|
# by the current user |
|
|
|
def allowed_parents(user=User.current) |
|
|
|
return @allowed_parents if @allowed_parents |
|
|
|
|
|
|
|
@allowed_parents = Project.allowed_to(user, :add_subprojects).to_a |
|
|
|
@allowed_parents = @allowed_parents - self_and_descendants |
|
|
|
if user.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?) |
|
|
@@ -701,6 +704,7 @@ class Project < ActiveRecord::Base |
|
|
|
# No write action allowed on closed projects |
|
|
|
return false |
|
|
|
end |
|
|
|
|
|
|
|
# No action allowed on disabled modules |
|
|
|
if action.is_a? Hash |
|
|
|
allowed_actions.include? "#{action[:controller]}/#{action[:action]}" |
|
|
@@ -801,8 +805,8 @@ class Project < ActiveRecord::Base |
|
|
|
if attrs.respond_to?(:to_unsafe_hash) |
|
|
|
attrs = attrs.to_unsafe_hash |
|
|
|
end |
|
|
|
|
|
|
|
return unless attrs.is_a?(Hash) |
|
|
|
|
|
|
|
attrs = attrs.deep_dup |
|
|
|
|
|
|
|
@unallowed_parent_id = nil |
|
|
@@ -979,6 +983,7 @@ class Project < ActiveRecord::Base |
|
|
|
project.wiki.pages.each do |page| |
|
|
|
# Skip pages without content |
|
|
|
next if page.content.nil? |
|
|
|
|
|
|
|
new_wiki_content = WikiContent.new(page.content.attributes.dup.except("id", "page_id", "updated_on")) |
|
|
|
new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id")) |
|
|
|
new_wiki_page.content = new_wiki_content |
|
|
@@ -1135,6 +1140,7 @@ class Project < ActiveRecord::Base |
|
|
|
# inherited roles will be added when copying the group membership |
|
|
|
role_ids = member.member_roles.reject(&:inherited?).collect(&:role_id) |
|
|
|
next if role_ids.empty? |
|
|
|
|
|
|
|
new_member.role_ids = role_ids |
|
|
|
new_member.project = self |
|
|
|
self.members << new_member |