diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-02-19 16:06:16 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-03-03 12:56:17 -0300 |
commit | dd071c4b6e9754a0abeec45ab2040d9e2d5a62b8 (patch) | |
tree | 9dda99bb987378cb6cbc95d236757d11f21176a6 /app/controllers/concerns | |
parent | 98fecb5f8e64c4c64c96d065bc342d986140367e (diff) | |
download | gitlab-ce-dd071c4b6e9754a0abeec45ab2040d9e2d5a62b8.tar.gz |
Bring one group board to CE
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/boards_responses.rb | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/app/controllers/concerns/boards_responses.rb b/app/controllers/concerns/boards_responses.rb index a145049dc7d..da830ec2cb1 100644 --- a/app/controllers/concerns/boards_responses.rb +++ b/app/controllers/concerns/boards_responses.rb @@ -1,10 +1,46 @@ module BoardsResponses + include Gitlab::Utils::StrongMemoize + + def board_params + params.require(:board).permit(:name, :weight, :milestone_id, :assignee_id, label_ids: []) + end + + def parent + strong_memoize(:parent) do + group? ? group : project + end + end + + def boards_path + if group? + group_boards_path(parent) + else + project_boards_path(parent) + end + end + + def board_path(board) + if group? + group_board_path(parent, board) + else + project_board_path(parent, board) + end + end + + def group? + instance_variable_defined?(:@group) + end + def authorize_read_list - authorize_action_for!(board.parent, :read_list) + ability = board.group_board? ? :read_group : :read_list + + authorize_action_for!(board.parent, ability) end def authorize_read_issue - authorize_action_for!(board.parent, :read_issue) + ability = board.group_board? ? :read_group : :read_issue + + authorize_action_for!(board.parent, ability) end def authorize_update_issue @@ -31,6 +67,10 @@ module BoardsResponses respond_with(@board) # rubocop:disable Gitlab/ModuleWithInstanceVariables end + def serialize_as_json(resource) + resource.as_json(only: [:id]) + end + def respond_with(resource) respond_to do |format| format.html |