2015-03-13 11:22:03 -04:00
|
|
|
class Projects::ProjectMembersController < Projects::ApplicationController
|
2016-06-02 12:05:06 -04:00
|
|
|
include MembershipActions
|
2017-12-05 09:03:16 -05:00
|
|
|
include MembersPresentation
|
2016-10-18 08:22:18 -04:00
|
|
|
include SortingHelper
|
2016-06-01 12:07:23 -04:00
|
|
|
|
2015-03-13 11:22:03 -04:00
|
|
|
# Authorize
|
2016-03-14 09:13:35 -04:00
|
|
|
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
|
2015-03-13 11:22:03 -04:00
|
|
|
|
|
|
|
def index
|
2017-07-07 10:40:41 -04:00
|
|
|
@sort = params[:sort].presence || sort_value_name
|
|
|
|
@group_links = @project.project_group_links
|
|
|
|
|
|
|
|
@skip_groups = @group_links.pluck(:group_id)
|
|
|
|
@skip_groups << @project.namespace_id unless @project.personal?
|
|
|
|
@skip_groups += @project.group.ancestors.pluck(:id) if @project.group
|
|
|
|
|
|
|
|
@project_members = MembersFinder.new(@project, current_user).execute
|
|
|
|
|
|
|
|
if params[:search].present?
|
|
|
|
@project_members = @project_members.joins(:user).merge(User.search(params[:search]))
|
|
|
|
@group_links = @group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id))
|
|
|
|
end
|
|
|
|
|
2018-04-04 05:19:47 -04:00
|
|
|
@project_members = present_members(@project_members.sort_by_attribute(@sort).page(params[:page]))
|
2017-12-05 09:03:16 -05:00
|
|
|
@requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user))
|
2017-07-07 10:40:41 -04:00
|
|
|
@project_member = @project.project_members.new
|
2015-03-13 11:22:03 -04:00
|
|
|
end
|
|
|
|
|
2017-08-15 06:27:37 -04:00
|
|
|
def import
|
|
|
|
@projects = current_user.authorized_projects.order_id_desc
|
|
|
|
end
|
|
|
|
|
2015-03-13 11:22:03 -04:00
|
|
|
def apply_import
|
2016-04-05 07:55:15 -04:00
|
|
|
source_project = Project.find(params[:source_project_id])
|
2016-04-05 07:29:48 -04:00
|
|
|
|
2016-04-05 07:55:15 -04:00
|
|
|
if can?(current_user, :read_project_member, source_project)
|
|
|
|
status = @project.team.import(source_project, current_user)
|
2016-04-05 07:29:48 -04:00
|
|
|
notice = status ? "Successfully imported" : "Import failed"
|
|
|
|
else
|
2016-04-05 08:37:06 -04:00
|
|
|
return render_404
|
2016-04-05 07:29:48 -04:00
|
|
|
end
|
2015-03-13 11:22:03 -04:00
|
|
|
|
2017-07-07 10:40:41 -04:00
|
|
|
redirect_to(project_project_members_path(project),
|
2015-03-13 11:22:03 -04:00
|
|
|
notice: notice)
|
|
|
|
end
|
|
|
|
|
2016-06-02 12:05:06 -04:00
|
|
|
# MembershipActions concern
|
|
|
|
alias_method :membershipable, :project
|
2015-03-13 11:22:03 -04:00
|
|
|
end
|