end
def transfer
- result = ::Projects::TransferContext.new(@project, current_user, project: params).execute(:admin)
+ result = ::Projects::TransferService.new(@project, current_user, project: params).execute(:admin)
if result
redirect_to [:admin, @project]
end
def destroy
- result = Files::DeleteContext.new(@project, current_user, params, @ref, @path).execute
+ result = Files::DeleteService.new(@project, current_user, params, @ref, @path).execute
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
end
def update
- result = Files::UpdateContext.new(@project, current_user, params, @ref, @path).execute
+ result = Files::UpdateService.new(@project, current_user, params, @ref, @path).execute
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
end
def bulk_update
- result = Issues::BulkUpdateContext.new(project, current_user, params).execute
+ result = Issues::BulkUpdateService.new(project, current_user, params).execute
redirect_to :back, notice: "#{result[:count]} issues updated"
end
def update
file_path = File.join(@path, File.basename(params[:file_name]))
- result = Files::CreateContext.new(@project, current_user, params, @ref, file_path).execute
+ result = Files::CreateService.new(@project, current_user, params, @ref, file_path).execute
if result[:status] == :success
flash[:notice] = "Your changes have been successfully committed"
before_filter :authorize_admin_note!, only: [:update, :destroy]
def index
- @notes = Notes::LoadContext.new(project, current_user, params).execute
+ @notes = Notes::LoadService.new(project, current_user, params).execute
notes_json = { notes: [] }
end
def create
- @note = Notes::CreateContext.new(project, current_user, params).execute
+ @note = Notes::CreateService.new(project, current_user, params).execute
respond_to do |format|
format.json { render_note_json(@note) }
end
def create
- @project = ::Projects::CreateContext.new(current_user, params[:project]).execute
+ @project = ::Projects::CreateService.new(current_user, params[:project]).execute
respond_to do |format|
flash[:notice] = 'Project was successfully created.' if @project.saved?
end
def update
- status = ::Projects::UpdateContext.new(@project, current_user, params).execute
+ status = ::Projects::UpdateService.new(@project, current_user, params).execute
respond_to do |format|
if status
end
def transfer
- ::Projects::TransferContext.new(project, current_user, params).execute
+ ::Projects::TransferService.new(project, current_user, params).execute
end
def show
end
def fork
- @forked_project = ::Projects::ForkContext.new(project, current_user).execute
+ @forked_project = ::Projects::ForkService.new(project, current_user).execute
respond_to do |format|
format.html do
if @project
return access_denied! unless can?(current_user, :download_code, @project)
- @search_results = Search::ProjectContext.new(@project, current_user, params).execute
+ @search_results = Search::ProjectService.new(@project, current_user, params).execute
else
- @search_results = Search::GlobalContext.new(current_user, params).execute
+ @search_results = Search::GlobalService.new(current_user, params).execute
end
end
end
-class BaseContext
+class BaseService
attr_accessor :project, :current_user, :params
def initialize(project, user, params)
module Files
- class BaseContext < ::BaseContext
+ class BaseService < ::BaseService
attr_reader :ref, :path
def initialize(project, user, params, ref, path = nil)
require_relative "base_context"
module Files
- class CreateContext < BaseContext
+ class CreateService < BaseService
def execute
allowed = if project.protected_branch?(ref)
can?(current_user, :push_code_to_protected_branches, project)
require_relative "base_context"
module Files
- class DeleteContext < BaseContext
+ class DeleteService < BaseService
def execute
allowed = if project.protected_branch?(ref)
can?(current_user, :push_code_to_protected_branches, project)
require_relative "base_context"
module Files
- class UpdateContext < BaseContext
+ class UpdateService < BaseService
def execute
allowed = if project.protected_branch?(ref)
can?(current_user, :push_code_to_protected_branches, project)
module Issues
- class BulkUpdateContext < BaseContext
+ class BulkUpdateService < BaseService
def execute
update_data = params[:update]
module Notes
- class CreateContext < BaseContext
+ class CreateService < BaseService
def execute
note = project.notes.new(params[:note])
note.author = current_user
module Notes
- class LoadContext < BaseContext
+ class LoadService < BaseService
def execute
target_type = params[:target_type]
target_id = params[:target_id]
module Projects
- class CreateContext < BaseContext
+ class CreateService < BaseService
def initialize(user, params)
@current_user, @params = user, params.dup
end
module Projects
- class ForkContext < BaseContext
+ class ForkService < BaseService
include Gitlab::ShellAdapter
def initialize(project, user)
module Projects
- class TransferContext < BaseContext
+ class TransferService < BaseService
def execute(role = :default)
namespace_id = params[:project].delete(:namespace_id)
allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin
module Projects
- class UpdateContext < BaseContext
+ class UpdateService < BaseService
def execute(role = :default)
params[:project].delete(:namespace_id)
# check that user is allowed to set specified visibility_level
module Search
- class GlobalContext
+ class GlobalService
attr_accessor :current_user, :params
def initialize(user, params)
module Search
- class ProjectContext
+ class ProjectService
attr_accessor :project, :current_user, :params
def initialize(project, user, params)