debian-mirror-gitlab/app/controllers/projects/project_members_controller.rb

58 lines
1.7 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Projects::ProjectMembersController < Projects::ApplicationController
include MembershipActions
2017-08-17 22:00:37 +05:30
include SortingHelper
2015-04-26 12:48:37 +05:30
# Authorize
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
2015-04-26 12:48:37 +05:30
def index
2017-08-17 22:00:37 +05:30
sort = params[:sort].presence || sort_value_name
redirect_to namespace_project_settings_members_path(@project.namespace, @project, sort: sort)
2015-04-26 12:48:37 +05:30
end
def update
@project_member = @project.project_members.find(params[:id])
2015-11-26 14:37:03 +05:30
return render_403 unless can?(current_user, :update_project_member, @project_member)
2015-04-26 12:48:37 +05:30
@project_member.update_attributes(member_params)
end
def resend_invite
2017-08-17 22:00:37 +05:30
redirect_path = namespace_project_settings_members_path(@project.namespace, @project)
2015-04-26 12:48:37 +05:30
@project_member = @project.project_members.find(params[:id])
2015-09-11 14:41:01 +05:30
2015-04-26 12:48:37 +05:30
if @project_member.invite?
@project_member.resend_invite
redirect_to redirect_path, notice: 'The invitation was successfully resent.'
else
redirect_to redirect_path, alert: 'The invitation has already been accepted.'
end
end
def apply_import
2016-06-02 11:05:42 +05:30
source_project = Project.find(params[:source_project_id])
if can?(current_user, :read_project_member, source_project)
status = @project.team.import(source_project, current_user)
notice = status ? "Successfully imported" : "Import failed"
else
return render_404
end
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
redirect_to(namespace_project_settings_members_path(project.namespace, project),
2015-04-26 12:48:37 +05:30
notice: notice)
end
protected
def member_params
2016-09-13 17:45:13 +05:30
params.require(:project_member).permit(:user_id, :access_level, :expires_at)
2015-04-26 12:48:37 +05:30
end
# MembershipActions concern
alias_method :membershipable, :project
2015-04-26 12:48:37 +05:30
end