mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
Merge remote-tracking branch 'origin/standalone_develop' into standalone_develop
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -43,7 +43,8 @@ class ProjectsController < ApplicationController
|
||||
@total_count =
|
||||
if category_id.blank? && params[:search].blank? && params[:topic_id].blank?
|
||||
# 默认查询时count性能问题处理
|
||||
ProjectCategory.sum("projects_count") - Project.visible.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id").where("organization_extensions.visibility =2").count
|
||||
not_category_count = Project.where(project_category_id: nil).count
|
||||
ProjectCategory.sum("projects_count") - Project.visible.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id").where("organization_extensions.visibility =2").count + not_category_count
|
||||
elsif params[:search].present? || params[:topic_id].present?
|
||||
@projects.total_count
|
||||
else
|
||||
@@ -59,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
|
||||
|
||||
@@ -64,10 +64,9 @@ class RepositoriesController < ApplicationController
|
||||
@entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder.repo_name)
|
||||
else
|
||||
@entries = Gitea::Repository::Entries::ListService.new(@owner, @project.identifier, ref: @ref).call
|
||||
return render_not_found if @entries.is_a?(Array) && @entries.blank?
|
||||
@entries = @entries.present? ? @entries.sort_by{ |hash| hash['type'] } : []
|
||||
@path = GiteaService.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
|
||||
@repo_detail = $gitea_client.get_repos_by_owner_repo(@owner.login, @project.identifier)
|
||||
return render_not_found if @entries.blank? && !@repo_detail["empty"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class VersionReleasesController < ApplicationController
|
||||
include ApplicationHelper
|
||||
before_action :load_repository
|
||||
before_action :set_user
|
||||
before_action :require_login, except: [:index, :show]
|
||||
@@ -126,6 +127,16 @@ class VersionReleasesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def download
|
||||
tip_exception(404, '您访问的页面不存在或已被删除') if params["tag_name"].blank? || params["filename"].blank?
|
||||
version = @repository.version_releases.find_by(tag_name: params["tag_name"])
|
||||
attachment = version.attachments.find_by(filename: params["filename"])
|
||||
tip_exception(404, '您访问的页面不存在或已被删除') if attachment.blank?
|
||||
send_file(absolute_path(local_path(attachment)), filename: attachment.title, stream: false, type: attachment.content_type.presence || 'application/octet-stream')
|
||||
update_downloads(attachment)
|
||||
# redirect_to "/api/attachments/#{attachment.uuid}"
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def set_user
|
||||
|
||||
Reference in New Issue
Block a user