Merge branch 'standalone_develop' into pre_trustie_server

This commit is contained in:
2024-04-30 15:47:37 +08:00
7 changed files with 23 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ class Admins::ProjectsController < Admins::BaseController
sort_by = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_on'
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
search = params[:search].to_s.strip
projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}")
projects = Project.where("name like ? OR identifier LIKE ?", "%#{search}%", "%#{search}%").order("#{sort_by} #{sort_direction}")
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)
end

View File

@@ -67,7 +67,18 @@ class Organizations::TeamsController < Organizations::BaseController
tip_exception("组织团队不允许被删除") if @team.owner?
ActiveRecord::Base.transaction do
Gitea::Organization::Team::DeleteService.call(@organization.gitea_token, @team.gtid)
other_user_ids = @organization.team_users.where.not(team_id: @team.id).pluck(:user_id)
team_user_ids = @team.team_users.pluck(:user_id)
# 当前删除团队中成员在其他组织其他团队不存在的成员需清除组织
remove_user_ids = team_user_ids - other_user_ids
Rails.logger.info "remove_user_ids ===========> #{remove_user_ids}"
@team.destroy!
if remove_user_ids.present?
User.where(id: remove_user_ids).each do |user|
@organization.organization_users.find_by(user_id: user.id).destroy!
Gitea::Organization::OrganizationUser::DeleteService.call(@organization.gitea_token, @organization.login, user.login)
end
end
end
render_ok
rescue Exception => e

View File

@@ -60,7 +60,10 @@ class ProjectsController < ApplicationController
OpenProjectDevOpsJob.set(wait: 5.seconds).perform_later(@project&.id, current_user.id)
UpdateProjectTopicJob.perform_later(@project.id) if @project.id.present?
end
rescue Exception => e
rescue Gitea::Api::ServerError => ex
uid_logger_error(ex.message)
tip_exception(ex.http_code, ex.message)
rescue ApplicationService::Error => e
uid_logger_error(e.message)
tip_exception(e.message)
end