Inherit board related services from BaseService

parent 50ac488c
module Boards module Boards
class BaseService class BaseService < ::BaseService
def initialize(project, user, params = {}) delegate :board, to: :project
@project = project
@board = project.board
@user = user
@params = params.dup
end
private
attr_reader :project, :board, :user, :params
end end
end end
...@@ -2,7 +2,7 @@ module Boards ...@@ -2,7 +2,7 @@ module Boards
module Issues module Issues
class ListService < Boards::BaseService class ListService < Boards::BaseService
def execute def execute
issues = IssuesFinder.new(user, filter_params).execute issues = IssuesFinder.new(current_user, filter_params).execute
issues = without_board_labels(issues) unless list.movable? issues = without_board_labels(issues) unless list.movable?
issues = with_list_label(issues) if list.movable? issues = with_list_label(issues) if list.movable?
issues issues
......
...@@ -2,7 +2,7 @@ module Boards ...@@ -2,7 +2,7 @@ module Boards
module Issues module Issues
class MoveService < Boards::BaseService class MoveService < Boards::BaseService
def execute(issue) def execute(issue)
return false unless user.can?(:update_issue, issue) return false unless can?(current_user, :update_issue, issue)
return false unless valid_move? return false unless valid_move?
update_service.execute(issue) update_service.execute(issue)
...@@ -23,7 +23,7 @@ module Boards ...@@ -23,7 +23,7 @@ module Boards
end end
def update_service def update_service
::Issues::UpdateService.new(project, user, issue_params) ::Issues::UpdateService.new(project, current_user, issue_params)
end end
def issue_params def issue_params
......
...@@ -15,7 +15,7 @@ module Boards ...@@ -15,7 +15,7 @@ module Boards
def create_list(params) def create_list(params)
label = find_or_create_label(params) label = find_or_create_label(params)
Lists::CreateService.new(project, user, label_id: label.id).execute Lists::CreateService.new(project, current_user, label_id: label.id).execute
end end
def find_or_create_label(params) def find_or_create_label(params)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment