gitlab-org--gitlab-foss/app/controllers/groups/group_members_controller.rb

55 lines
1.6 KiB
Ruby
Raw Normal View History

2015-03-12 11:08:48 -04:00
class Groups::GroupMembersController < Groups::ApplicationController
include MembershipActions
include SortingHelper
# Authorize
before_action :authorize_admin_group_member!, except: [:index, :leave, :request_access]
def index
@sort = params[:sort].presence || sort_value_name
@project = @group.projects.find(params[:project_id]) if params[:project_id]
@members = GroupMembersFinder.new(@group).execute
@members = @members.non_invite unless can?(current_user, :admin_group, @group)
@members = @members.search(params[:search]) if params[:search].present?
@members = @members.sort(@sort)
2016-10-18 08:22:18 -04:00
@members = @members.page(params[:page]).per(50)
@members.includes(:user)
@requesters = AccessRequestsFinder.new(@group).execute(current_user)
@group_member = @group.group_members.new
end
def update
@group_member = @group.group_members.find(params[:id])
return render_403 unless can?(current_user, :update_group_member, @group_member)
@group_member.update_attributes(member_params)
end
2015-04-10 09:26:03 -04:00
def resend_invite
2015-04-14 09:16:00 -04:00
redirect_path = group_group_members_path(@group)
2015-04-10 09:26:03 -04:00
@group_member = @group.group_members.find(params[:id])
2015-04-14 09:16:00 -04:00
2015-04-10 09:26:03 -04:00
if @group_member.invite?
@group_member.resend_invite
2015-04-14 09:16:00 -04:00
redirect_to redirect_path, notice: 'The invitation was successfully resent.'
2015-04-10 09:26:03 -04:00
else
2015-04-14 09:16:00 -04:00
redirect_to redirect_path, alert: 'The invitation has already been accepted.'
2015-04-10 09:26:03 -04:00
end
end
protected
def member_params
params.require(:group_member).permit(:access_level, :user_id, :expires_at)
end
# MembershipActions concern
alias_method :membershipable, :group
end