新增: 组织下项目协作者添加当前用户

This commit is contained in:
yystopf 2022-08-04 17:28:14 +08:00
parent a9811768d4
commit f8268accc0
2 changed files with 33 additions and 6 deletions

View File

@ -26,6 +26,9 @@ class MembersController < ApplicationController
@total_count = scope.size
@members = paginate(scope)
if @project.owner.is_a?(Organization) && (params[:page].to_i == 1 || params[:page].blank?)
@current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take
end
end
def remove
@ -65,6 +68,8 @@ class MembersController < ApplicationController
end
def check_member_not_exists!
@current_user_header_team = Team.joins(:team_users, :team_projects).where(team_projects: {project_id: @project.id}, team_users: {user_id: current_user.id}).order(authorize: :desc).take
return render_error("用户为组织成员,请到组织下操作!") if @current_user_header_team.present?
return render_error("user_id为#{params[:user_id]}的用户还不是项目成员") unless member_exists?
end

View File

@ -1,9 +1,31 @@
json.total_count @total_count
json.members @members do |member|
if member.user.present?
json.partial! 'member', user: member.user
json.is_owner @project.owner?(member.user)
json.role member.roles.last.name
json.role_name t("roles.#{member.roles.last.name}")
json.members do
if @current_user_header_team.present?
json.child! do
json.partial! 'member', user: current_user
json.is_owner @project.owner?(current_user)
case @current_user_header_team.authorize
when 'read'
json.role 'Reporter'
json.role_name t("roles.Reporter")
when 'write'
json.role 'Developer'
json.role_name t("roles.Developer")
when 'admin'
json.role 'Manager'
json.role_name t("roles.Manager")
when 'owner'
json.role 'Manager'
json.role_name t("roles.Manager")
end
end
end
@members.each do |member|
json.child! do
json.partial! 'member', user: member.user
json.is_owner @project.owner?(member.user)
json.role member.roles.last.name
json.role_name t("roles.#{member.roles.last.name}")
end
end
end