diff options
author | David Alexander <davidpaulalexander@gmail.com> | 2016-03-14 16:13:35 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-06-14 13:12:02 +0300 |
commit | 17c22156c5fa5663aae65178ed38cbeef9a80b7e (patch) | |
tree | 5bd90d34c7360c892f6ea57dd1d3e4a6350a51cd /app/controllers/projects/project_members_controller.rb | |
parent | 0c0ef7dfb6afb1695b62037fc0fa5aba6ce697d7 (diff) |
Initial implementation of user access request to projects
Diffstat (limited to 'app/controllers/projects/project_members_controller.rb')
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index cdea5f0b776..ba5ef30be38 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -1,10 +1,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController # Authorize - before_action :authorize_admin_project_member!, except: [:leave, :index] + before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access] def index @project_members = @project.project_members - @project_members = @project_members.non_invite unless can?(current_user, :admin_project, @project) + @project_members = @project_members.non_pending unless can?(current_user, :admin_project, @project) if params[:search].present? users = @project.users.search(params[:search]).to_a @@ -93,6 +93,33 @@ class Projects::ProjectMembersController < Projects::ApplicationController end end + def request_access + redirect_path = namespace_project_path(@project.namespace, @project) + # current_user + # @project + @project_member = ProjectMember.new(source: @project, access_level: ProjectMember::DEVELOPER, user_id: current_user.id, created_by_id: current_user.id, requested: true) + @project_member.save! + + + redirect_to redirect_path, notice: 'Your request for access has been queued for review.' + end + + def approval + @project_member = @project.project_members.find(params[:id]) + + return render_403 unless can?(current_user, :update_project_member, @project_member) + + @project_member.requested = nil + @project_member.save! + + respond_to do |format| + format.html do + redirect_to namespace_project_project_members_path(@project.namespace, @project) + end + format.js { render nothing: true } + end + end + def apply_import source_project = Project.find(params[:source_project_id]) |