[FIX]little vliad about team_user
This commit is contained in:
parent
ddaca5bafc
commit
629f3fbbe1
|
@ -11,7 +11,7 @@ class Organizations::OrganizationUsersController < Organizations::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user)
|
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user.id)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@organization_user.destroy!
|
@organization_user.destroy!
|
||||||
TeamUser.where(organization_id: @organization.id, user_id: @operate_user.id).map{|u| u.destroy!}
|
TeamUser.where(organization_id: @organization.id, user_id: @operate_user.id).map{|u| u.destroy!}
|
||||||
|
@ -26,7 +26,7 @@ class Organizations::OrganizationUsersController < Organizations::BaseController
|
||||||
def quit
|
def quit
|
||||||
@organization_user = @organization.organization_users.find_by(user_id: current_user.id)
|
@organization_user = @organization.organization_users.find_by(user_id: current_user.id)
|
||||||
tip_exception("您不在该组织中") if @organization_user.nil?
|
tip_exception("您不在该组织中") if @organization_user.nil?
|
||||||
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(current_user)
|
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(current_user.id)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@organization_user.destroy!
|
@organization_user.destroy!
|
||||||
TeamUser.where(organization_id: @organization.id, user_id: current_user.id).map{|u| u.destroy!}
|
TeamUser.where(organization_id: @organization.id, user_id: current_user.id).map{|u| u.destroy!}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Organizations::TeamUsersController < Organizations::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user)
|
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(@operate_user.id)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@team_user.destroy!
|
@team_user.destroy!
|
||||||
Gitea::Organization::TeamUser::DeleteService.call(@organization.gitea_token, @team.gtid, @operate_user.login)
|
Gitea::Organization::TeamUser::DeleteService.call(@organization.gitea_token, @team.gtid, @operate_user.login)
|
||||||
|
@ -39,7 +39,7 @@ class Organizations::TeamUsersController < Organizations::BaseController
|
||||||
def quit
|
def quit
|
||||||
@team_user = @team.team_users.find_by(user_id: current_user.id)
|
@team_user = @team.team_users.find_by(user_id: current_user.id)
|
||||||
tip_exception("您不在该组织团队中") if @team_user.nil?
|
tip_exception("您不在该组织团队中") if @team_user.nil?
|
||||||
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(current_user)
|
tip_exception("您不能从 Owner 团队中删除最后一个用户") if @organization.is_owner_team_last_one?(current_user.id)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@team_user.destroy!
|
@team_user.destroy!
|
||||||
Gitea::Organization::TeamUser::DeleteService.call(@organization.gitea_token, @team.gtid, current_user.login)
|
Gitea::Organization::TeamUser::DeleteService.call(@organization.gitea_token, @team.gtid, current_user.login)
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Organizations::TeamsController < Organizations::BaseController
|
||||||
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
|
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if @organization.is_owner?(current_user)
|
if @organization.is_owner?(current_user) || current_user.admin?
|
||||||
@teams = @organization.teams
|
@teams = @organization.teams
|
||||||
else
|
else
|
||||||
@teams = @organization.teams.joins(:team_users).where(team_users: {user_id: current_user.id})
|
@teams = @organization.teams.joins(:team_users).where(team_users: {user_id: current_user.id})
|
||||||
|
@ -35,6 +35,7 @@ class Organizations::TeamsController < Organizations::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
tip_exception("组织团队不允许被删除") if @team.owner?
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid)
|
Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid)
|
||||||
@team.destroy!
|
@team.destroy!
|
||||||
|
|
Loading…
Reference in New Issue