diff options
author | Rémy Coutable <remy@rymai.me> | 2016-06-01 19:07:23 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-06-14 14:07:26 +0300 |
commit | d71fbe0dbdb3b7aba6f71e6d3d50daaa890769e9 (patch) | |
tree | 9e0c6fa7768bb5899ddf9e25d009347e462fda9d /app/controllers/projects/project_members_controller.rb | |
parent | d26f81239a33b80694783ee35f0da0e2ed082c9b (diff) |
Factorize #request_access and #approve_access_request into a new AccessRequestActions controller concern
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/controllers/projects/project_members_controller.rb')
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index c979c5e9fa9..c61eda95bc7 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -1,4 +1,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController + include AccessRequestActions + # Authorize before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access] @@ -99,23 +101,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController end end - def request_access - @project.request_access(current_user) - - redirect_to namespace_project_path(@project.namespace, @project), - notice: 'Your request for access has been queued for review.' - end - - def approve - @project_member = @project.project_members.request.find(params[:id]) - - return render_403 unless can?(current_user, :update_project_member, @project_member) - - @project_member.accept_request - - redirect_to namespace_project_project_members_path(@project.namespace, @project) - end - def apply_import source_project = Project.find(params[:source_project_id]) @@ -135,4 +120,17 @@ class Projects::ProjectMembersController < Projects::ApplicationController def member_params params.require(:project_member).permit(:user_id, :access_level) end + + # AccessRequestActions concern + def access_requestable_resource + @project + end + + def access_requestable_resource_path + namespace_project_path(@project.namespace, @project) + end + + def access_requestable_resource_members_path + namespace_project_project_members_path(@project.namespace, @project) + end end |