debian-mirror-gitlab/app/controllers/groups/group_members_controller.rb

55 lines
1.6 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Groups::GroupMembersController < Groups::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_group_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
2015-04-26 12:48:37 +05:30
@project = @group.projects.find(params[:project_id]) if params[:project_id]
2017-08-17 22:00:37 +05:30
@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)
@members = @members.page(params[:page]).per(50)
@members.includes(:user)
2015-04-26 12:48:37 +05:30
2016-11-03 12:29:30 +05:30
@requesters = AccessRequestsFinder.new(@group).execute(current_user)
2015-11-26 14:37:03 +05:30
@group_member = @group.group_members.new
2015-04-26 12:48:37 +05:30
end
def update
2015-11-26 14:37:03 +05:30
@group_member = @group.group_members.find(params[:id])
2015-09-11 14:41:01 +05:30
2015-11-26 14:37:03 +05:30
return render_403 unless can?(current_user, :update_group_member, @group_member)
2015-09-11 14:41:01 +05:30
2015-11-26 14:37:03 +05:30
@group_member.update_attributes(member_params)
2015-04-26 12:48:37 +05:30
end
def resend_invite
redirect_path = group_group_members_path(@group)
2015-09-11 14:41:01 +05:30
2015-04-26 12:48:37 +05:30
@group_member = @group.group_members.find(params[:id])
if @group_member.invite?
@group_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
protected
def member_params
2016-09-13 17:45:13 +05:30
params.require(:group_member).permit(:access_level, :user_id, :expires_at)
2015-04-26 12:48:37 +05:30
end
# MembershipActions concern
alias_method :membershipable, :group
2015-04-26 12:48:37 +05:30
end