gitlab-org--gitlab-foss/app/services/projects/update_service.rb
Dmitriy Zaporozhets 1d2bdb4d58
Move all Context classes into Services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-01-16 19:03:42 +02:00

19 lines
699 B
Ruby

module Projects
class UpdateService < BaseService
def execute(role = :default)
params[:project].delete(:namespace_id)
# check that user is allowed to set specified visibility_level
unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:project][:visibility_level])
params[:project].delete(:visibility_level)
end
new_branch = params[:project].delete(:default_branch)
if project.repository.exists? && new_branch && new_branch != project.default_branch
project.change_head(new_branch)
end
project.update_attributes(params[:project], as: role)
end
end
end