Refactor abilities. Added ProjectUpdate context. Fixed few bugs with namespaces
This commit is contained in:
parent
a1ffc673b9
commit
eb1004f789
18 changed files with 127 additions and 53 deletions
21
app/contexts/project_update_context.rb
Normal file
21
app/contexts/project_update_context.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class ProjectUpdateContext < BaseContext
|
||||
def execute(role = :default)
|
||||
namespace_id = params[:project].delete(:namespace_id)
|
||||
|
||||
if namespace_id.present?
|
||||
if namespace_id == Namespace.global_id
|
||||
if project.namespace.present?
|
||||
# Transfer to global namespace from anyone
|
||||
project.transfer(nil)
|
||||
end
|
||||
elsif namespace_id.to_i != project.namespace_id
|
||||
# Transfer to someone namespace
|
||||
namespace = Namespace.find(namespace_id)
|
||||
project.transfer(namespace)
|
||||
end
|
||||
end
|
||||
|
||||
project.update_attributes(params[:project], as: role)
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue