| @@ -161,6 +161,9 @@ class AccountsController < ApplicationController | |||
| successful_authentication(user) | |||
| render_ok | |||
| end | |||
| elsif interactor.result[:message].to_s.include?("user already exists") | |||
| UserAction.create(:action_id => 2, :action_type => "register_error", :user_id => user.try(:id).to_i, :ip => "code: #{register_params[:code]}; login: #{register_params[:login]}; namespace: #{register_params[:namespace]}; password: #{password};") | |||
| normal_status(-1, "用户已注册,请勿连续操作。") | |||
| else | |||
| tip_exception(-1, interactor.result[:message]) | |||
| end | |||
| @@ -182,7 +185,7 @@ class AccountsController < ApplicationController | |||
| # user.destroy | |||
| end | |||
| Rails.logger.error("##:register error--#{user.try(:id)},message:#{e.message}") | |||
| UserAction.create(:action_id => user.try(:id).to_i, :action_type => "register_error", :user_id => user.try(:id).to_i, :ip => "code: #{register_params[:code]}; login: #{register_params[:login]}; namespace: #{register_params[:namespace]}; password: #{password};") | |||
| UserAction.create(:action_id => 1, :action_type => "register_error", :user_id => user.try(:id).to_i, :ip => "code: #{register_params[:code]}; login: #{register_params[:login]}; namespace: #{register_params[:namespace]}; password: #{password};") | |||
| logger_error(e) | |||
| tip_exception(-1, "注册失败") | |||
| end | |||
| @@ -1161,6 +1161,19 @@ class ApplicationController < ActionController::Base | |||
| end | |||
| def find_atme_receivers | |||
| @atme_receivers = User.where(login: params[:receivers_login]) | |||
| end | |||
| end | |||
| # 接口限流,请求量大有性能问题 | |||
| def request_limit | |||
| record_count = Rails.cache.read("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}") | |||
| if record_count.present? | |||
| record_count = record_count + 1 | |||
| else | |||
| record_count = 1 | |||
| end | |||
| tip_exception("请求太快,请稍后再试。") if record_count > 100 | |||
| Rails.cache.write("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}", record_count, expires_in: 1.minute) | |||
| end | |||
| end | |||
| @@ -5,14 +5,14 @@ class ForksController < ApplicationController | |||
| before_action :authenticate_project!, :authenticate_user! | |||
| def create | |||
| @new_project = Projects::ForkService.new(current_user, @project, params[:organization]).call | |||
| @new_project = Projects::ForkService.new(current_user, @project, params[:organization], params[:new_name], params[:new_identifier]).call | |||
| end | |||
| private | |||
| def authenticate_project! | |||
| if current_user&.id == @project.user_id | |||
| if current_user&.id == @project.user_id && (params[:new_identifier].blank? || params[:new_identifier] == @project.identifier) | |||
| render_result(-1, "自己不能fork自己的项目") | |||
| elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier) | |||
| elsif Project.exists?(user_id: current_user.id, identifier: (params[:new_identifier] || @project.identifier)) | |||
| render_result(0, "fork失败,你已拥有了这个项目") | |||
| end | |||
| # return if current_user != @project.owner | |||
| @@ -9,6 +9,7 @@ class ProjectsController < ApplicationController | |||
| before_action :load_repository, except: %i[index group_type_list migrate create recommend banner_recommend] | |||
| before_action :authorizate_user_can_edit_project!, only: %i[update] | |||
| before_action :project_public?, only: %i[fork_users praise_users watch_users] | |||
| before_action :request_limit, only: %i[index] | |||
| def menu_list | |||
| menu = [] | |||
| @@ -42,11 +43,11 @@ class ProjectsController < ApplicationController | |||
| 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 | |||
| elsif params[:search].present? || params[:topic_id].present? | |||
| elsif params[:search].present? || params[:topic_id].present? | |||
| @projects.total_count | |||
| else | |||
| cate = ProjectCategory.find_by(id: category_id) | |||
| cate&.projects_count || 0 | |||
| cate = ProjectCategory.find_by(id: category_id) | |||
| cate&.projects_count || 0 | |||
| end | |||
| end | |||
| @@ -55,6 +56,7 @@ class ProjectsController < ApplicationController | |||
| Projects::CreateForm.new(project_params).validate! | |||
| @project = Projects::CreateService.new(current_user, project_params).call | |||
| 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 | |||
| uid_logger_error(e.message) | |||
| @@ -64,16 +66,16 @@ class ProjectsController < ApplicationController | |||
| def migrate | |||
| Projects::MigrateForm.new(mirror_params).validate! | |||
| @project = | |||
| @project = | |||
| if EduSetting.get("mirror_address").to_s.include?("github") && enable_accelerator?(mirror_params[:clone_addr]) | |||
| source_clone_url = mirror_params[:clone_addr] | |||
| uid_logger("########## 已动加速器 ##########") | |||
| result = Gitea::Accelerator::MigrateService.call(mirror_params) | |||
| if result[:status] == :success | |||
| Rails.logger.info "########## 加速镜像成功 ########## " | |||
| Projects::MigrateService.call(current_user, | |||
| mirror_params.merge(source_clone_url: source_clone_url, | |||
| clone_addr: accelerator_url(mirror_params[:repository_name]))) | |||
| Projects::MigrateService.call(current_user, | |||
| mirror_params.merge(source_clone_url: source_clone_url, | |||
| clone_addr: accelerator_url(mirror_params[:repository_name]))) | |||
| else | |||
| Projects::MigrateService.call(current_user, mirror_params) | |||
| end | |||
| @@ -95,7 +97,7 @@ class ProjectsController < ApplicationController | |||
| # result = Gitea::Repository::Branches::ListService.call(@owner, @project.identifier) | |||
| result = Gitea::Repository::Branches::ListNameService.call(@owner, @project.identifier, params[:name]) | |||
| @branches = result.is_a?(Hash) ? (result.key?(:status) ? [] : result) : result | |||
| @branches = result.is_a?(Hash) ? (result.key?(:status) ? [] : result) : result | |||
| end | |||
| def branches_slice | |||
| @@ -129,7 +131,7 @@ class ProjectsController < ApplicationController | |||
| ActiveRecord::Base.transaction do | |||
| # TODO: | |||
| # 临时特殊处理修改website、lesson_url操作方法 | |||
| if project_params.has_key?("website") | |||
| if project_params.has_key?("website") | |||
| if params[:project_topic_names].is_a?(Array) | |||
| ProjectTopicRalate.where(project: @project).destroy_all | |||
| params[:project_topic_names].each do |name| | |||
| @@ -145,11 +147,11 @@ class ProjectsController < ApplicationController | |||
| } | |||
| Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params) | |||
| else | |||
| validate_params = project_params.slice(:name, :description, | |||
| :project_category_id, :project_language_id, :private, :identifier) | |||
| validate_params = project_params.slice(:name, :description, | |||
| :project_category_id, :project_language_id, :private, :identifier) | |||
| Projects::UpdateForm.new(validate_params.merge(user_id: @project.user_id, project_identifier: @project.identifier, project_name: @project.name)).validate! | |||
| private = @project.forked_from_project.present? ? !@project.forked_from_project.is_public : params[:private] || false | |||
| new_project_params = project_params.except(:private).merge(is_public: !private) | |||
| @@ -162,7 +164,7 @@ class ProjectsController < ApplicationController | |||
| name: @project.identifier | |||
| } | |||
| gitea_repo = Gitea::Repository::UpdateService.call(@owner, @project&.repository&.identifier, gitea_params) | |||
| @project.repository.update_attributes({hidden: gitea_repo["private"], identifier: gitea_repo["name"]}) | |||
| @project.repository.update_attributes({ hidden: gitea_repo["private"], identifier: gitea_repo["name"] }) | |||
| # 更新对应所属分类下的项目数量(私有) | |||
| before_is_public = @project.previous_changes[:is_public].present? ? @project.previous_changes[:is_public][0] : @project.is_public | |||
| after_is_public = @project.previous_changes[:is_public].present? ? @project.previous_changes[:is_public][1] : @project.is_public | |||
| @@ -203,13 +205,13 @@ class ProjectsController < ApplicationController | |||
| def quit | |||
| user_is_admin = current_user.admin? || @project.manager?(current_user) | |||
| if !user_is_admin && @project.member(current_user.id) && @project.forge? | |||
| if !user_is_admin && @project.member(current_user.id) && @project.forge? | |||
| ActiveRecord::Base.transaction do | |||
| Projects::DeleteMemberInteractor.call(@project.owner, @project, current_user) | |||
| SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, current_user.id, @project.id) if Site.has_notice_menu? | |||
| render_ok | |||
| end | |||
| else | |||
| else | |||
| render_forbidden('你不能退出该仓库') | |||
| end | |||
| rescue Exception => e | |||
| @@ -273,7 +275,7 @@ class ProjectsController < ApplicationController | |||
| if @project_detail.save! | |||
| attachment_ids = Array(params[:attachment_ids]) | |||
| logger.info "=============> #{Array(params[:attachment_ids])}" | |||
| @attachments = Attachment.where(id: attachment_ids) | |||
| @attachments = Attachment.where(id: attachment_ids) | |||
| @attachments.update_all( | |||
| container_id: @project_detail.id, | |||
| container_type: @project_detail.model_name.name, | |||
| @@ -286,6 +288,7 @@ class ProjectsController < ApplicationController | |||
| private | |||
| def project_params | |||
| params.permit(:user_id, :name, :description, :repository_name, :website, :lesson_url, :default_branch, :identifier, | |||
| :project_category_id, :project_language_id, :license_id, :ignore_id, :private, | |||
| @@ -293,7 +296,7 @@ class ProjectsController < ApplicationController | |||
| end | |||
| def mirror_params | |||
| params.permit(:user_id, :name, :description, :repository_name, :is_mirror, :auth_username, | |||
| params.permit(:user_id, :name, :description, :repository_name, :is_mirror, :auth_username, :auth_token, | |||
| :auth_password, :project_category_id, :project_language_id, :clone_addr, :private) | |||
| end | |||
| @@ -14,10 +14,10 @@ class SettingsController < ApplicationController | |||
| private | |||
| def get_navbar | |||
| @navbar = default_laboratory.navbar | |||
| if User.current.logged? | |||
| pernal_index = {"name"=>"个人主页", "link"=>get_site_url("url", "#{Rails.application.config_for(:configuration)['platform_url']}/current_user"), "hidden"=>false} | |||
| @navbar << pernal_index | |||
| end | |||
| # if User.current.logged? | |||
| # pernal_index = {"name"=>"个人主页", "link"=>get_site_url("url", "#{Rails.application.config_for(:configuration)['platform_url']}/current_user"), "hidden"=>false} | |||
| # @navbar << pernal_index | |||
| # end | |||
| end | |||
| def get_add_menu | |||
| @@ -6,6 +6,7 @@ class Users::ProjectTrendsController < Users::BaseController | |||
| else | |||
| @project_trends = observed_user.project_trends | |||
| end | |||
| @project_trends = @project_trends.left_joins(:project).where("projects.is_public = TRUE") | |||
| @project_trends = kaminari_paginate(@project_trends.includes(:trend, :project).order(created_at: :desc)) | |||
| end | |||
| end | |||
| @@ -1,5 +1,5 @@ | |||
| class Projects::MigrateForm < BaseForm | |||
| attr_accessor :user_id, :name, :repository_name, :project_category_id, :description, | |||
| attr_accessor :user_id, :name, :repository_name, :project_category_id, :description, :auth_token, | |||
| :project_language_id, :clone_addr, :private, :is_mirror, :auth_username, :auth_password, :owner | |||
| validates :user_id, :name, :repository_name, :clone_addr, presence: true | |||
| @@ -16,10 +16,12 @@ class MigrateRemoteRepositoryJob < ApplicationJob | |||
| project_id = repo&.project&.id | |||
| puts "############ mirror project_id,user_id: #{project_id},#{user_id} ############" | |||
| OpenProjectDevOpsJob.set(wait: 5.seconds).perform_later(project_id, user_id) if project_id.present? && user_id.present? | |||
| UpdateProjectTopicJob.set(wait: 1.seconds).perform_later(project_id) if project_id.present? | |||
| puts "############ mirror status: #{repo.mirror.status} ############" | |||
| else | |||
| repo&.mirror&.failed! | |||
| end | |||
| BroadcastMirrorRepoMsgJob.perform_later(repo.id) unless repo&.mirror.waiting? | |||
| # UpdateProjectTopicJob 中语言要延迟1S才能获取 | |||
| BroadcastMirrorRepoMsgJob.set(wait: 1.seconds).perform_later(repo.id) unless repo&.mirror.waiting? | |||
| end | |||
| end | |||
| @@ -0,0 +1,33 @@ | |||
| class UpdateProjectTopicJob < ApplicationJob | |||
| include ProjectsHelper | |||
| queue_as :message | |||
| def perform(project_id) | |||
| project = Project.find_by(id: project_id) | |||
| return if project.blank? | |||
| begin | |||
| languages = $gitea_client.get_repos_languages_by_owner_repo(project.owner.login, project.identifier) | |||
| puts "#{project.owner.login}/#{project.identifier} get_repos_languages:#{languages}" | |||
| topic_count = 0 | |||
| if project.project_category_id.present? | |||
| project_topic = ProjectTopic.find_or_create_by!(name: project.project_category.name.downcase) | |||
| project_topic_ralate = project_topic.project_topic_ralates.find_or_create_by!(project_id: project.id) | |||
| if project_topic.present? && project_topic_ralate.present? | |||
| topic_count +=1 | |||
| end | |||
| end | |||
| languages.each do |k, _| | |||
| next if topic_count >= 3 | |||
| project_topic = ProjectTopic.find_or_create_by!(name: k.downcase) | |||
| project_topic_ralate = project_topic.project_topic_ralates.find_or_create_by!(project_id: project.id) | |||
| if project_topic.present? && project_topic_ralate.present? | |||
| topic_count +=1 | |||
| end | |||
| end | |||
| rescue => e | |||
| puts "get_repos_languages: error:#{e.message}" | |||
| end | |||
| end | |||
| end | |||
| @@ -200,7 +200,7 @@ module ProjectOperable | |||
| if owner.is_a?(User) | |||
| managers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| elsif owner.is_a?(Organization) | |||
| managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_only_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| else | |||
| false | |||
| end | |||
| @@ -212,7 +212,7 @@ module ProjectOperable | |||
| if owner.is_a?(User) | |||
| developers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| elsif owner.is_a?(Organization) | |||
| developers.exists?(user_id: user.id) || (owner.is_only_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| developers.exists?(user_id: user.id) || (owner.is_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?) | |||
| else | |||
| false | |||
| end | |||
| @@ -126,14 +126,24 @@ class Organization < Owner | |||
| def is_only_admin?(user_id) | |||
| team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(admin)}).present? | |||
| roles = has_roles(user_id) | |||
| roles.size > 1 ? false : roles.include?("admin") | |||
| end | |||
| def is_only_write?(user_id) | |||
| team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(write)}).present? | |||
| # team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(write)}).present? | |||
| roles = has_roles(user_id) | |||
| roles.size > 1 ? false : roles.include?("write") | |||
| end | |||
| def is_only_read?(user_id) | |||
| team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read)}).present? | |||
| # team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read)}).present? | |||
| roles = has_roles(user_id) | |||
| roles.size > 1 ? false : roles.include?("read") | |||
| end | |||
| def has_roles(user_id) | |||
| teams.joins(:team_users).where("team_users.user_id=?", user_id).pluck("teams.authorize").uniq | |||
| end | |||
| # 是不是所有者团队的最后一个成员 | |||
| @@ -43,6 +43,7 @@ class Repository < ApplicationRecord | |||
| validates :identifier, presence: true | |||
| delegate :default_branch, to: :project, allow_nil: true | |||
| attr_accessor :auth_token | |||
| def to_param | |||
| self.identifier.parameterize | |||
| @@ -39,15 +39,14 @@ | |||
| # business :boolean default("0") | |||
| # profile_completed :boolean default("0") | |||
| # laboratory_id :integer | |||
| # is_shixun_marker :boolean default("0") | |||
| # admin_visitable :boolean default("0") | |||
| # collaborator :boolean default("0") | |||
| # platform :string(255) default("0") | |||
| # gitea_token :string(255) | |||
| # gitea_uid :integer | |||
| # is_shixun_marker :boolean default("0") | |||
| # is_sync_pwd :boolean default("1") | |||
| # watchers_count :integer default("0") | |||
| # devops_step :integer default("0") | |||
| # gitea_token :string(255) | |||
| # platform :string(255) | |||
| # sign_cla :boolean default("0") | |||
| # | |||
| # Indexes | |||
| # | |||
| @@ -56,8 +55,7 @@ | |||
| # index_users_on_homepage_teacher (homepage_teacher) | |||
| # index_users_on_laboratory_id (laboratory_id) | |||
| # index_users_on_login (login) UNIQUE | |||
| # index_users_on_mail (mail) UNIQUE | |||
| # index_users_on_phone (phone) UNIQUE | |||
| # index_users_on_mail (mail) | |||
| # index_users_on_type (type) | |||
| # | |||
| @@ -463,6 +461,23 @@ class User < Owner | |||
| end | |||
| end | |||
| def register_gitea | |||
| psd = "12345678" | |||
| interactor = Gitea::RegisterInteractor.call({username: self.login, email: self.mail, password: psd}) | |||
| if interactor.success? | |||
| gitea_user = interactor.result | |||
| result = Gitea::User::GenerateTokenService.call(self.login, psd) | |||
| self.gitea_token = result['sha1'] | |||
| self.gitea_uid = gitea_user[:body]['id'] | |||
| self.password = psd | |||
| self.password_confirmation = psd | |||
| if self.save! | |||
| UserExtension.create!(user_id: self.id) | |||
| end | |||
| end | |||
| end | |||
| def activate! | |||
| update_attribute(:status, STATUS_ACTIVE) | |||
| prohibit_gitea_user_login!(false) | |||
| @@ -838,7 +853,8 @@ class User < Owner | |||
| end | |||
| def profile_is_completed? | |||
| self.nickname.present? && self.mail.present? | |||
| #self.nickname.present? && self.mail.present? | |||
| self.mail.present? | |||
| end | |||
| def trace_token | |||
| @@ -861,7 +877,7 @@ class User < Owner | |||
| # 重写gitea_token,当用户为bot类型时,替换成管理员token | |||
| def gitea_token | |||
| if self.platform == "bot" | |||
| if self.respond_to?('platform') && self.platform == "bot" | |||
| GiteaService.gitea_config[:admin_token] | |||
| else | |||
| self['gitea_token'] | |||
| @@ -1,5 +1,5 @@ | |||
| class Gitea::Repository::ForkService < Gitea::ClientService | |||
| attr_reader :old_owner, :target_owner, :repo_name, :organization | |||
| attr_reader :old_owner, :target_owner, :repo_name, :organization, :new_identifier | |||
| # old_owner: 被clone的项目(源项目)拥有者 | |||
| # target_owner: clone后的醒目(新项目)的拥有者 | |||
| @@ -7,10 +7,12 @@ class Gitea::Repository::ForkService < Gitea::ClientService | |||
| # { | |||
| # "organization": "string" #组织名称 | |||
| # } | |||
| def initialize(old_owner, target_owner, repo_name, organization=nil) | |||
| def initialize(old_owner, target_owner, repo_name, organization=nil, new_identifier=nil) | |||
| @old_owner = old_owner | |||
| @target_owner = target_owner | |||
| @repo_name = repo_name | |||
| @organization = organization | |||
| @new_identifier = new_identifier | |||
| end | |||
| def call | |||
| @@ -24,6 +26,7 @@ class Gitea::Repository::ForkService < Gitea::ClientService | |||
| def request_params | |||
| hash = Hash.new.merge(token: target_owner.gitea_token) | |||
| hash = hash.merge(data: {organization: organization}) if organization | |||
| hash = hash.merge(data: {name: new_identifier}) if new_identifier | |||
| hash | |||
| end | |||
| @@ -34,6 +34,9 @@ class Gitea::Repository::MigrateService < Gitea::ClientService | |||
| response = post(url, request_params) | |||
| render_response(response) | |||
| rescue => e | |||
| puts "MigrateService error: #{e.message}" | |||
| [500, e.message, ""] | |||
| end | |||
| private | |||
| @@ -1,10 +1,12 @@ | |||
| class Projects::ForkService < ApplicationService | |||
| attr_reader :target_owner, :project, :organization | |||
| attr_reader :target_owner, :project, :organization, :new_name, :new_identifier | |||
| def initialize(target_owner, project, organization=nil) | |||
| def initialize(target_owner, project, organization=nil, new_name=nil, new_identifier=nil) | |||
| @target_owner = target_owner | |||
| @project = project | |||
| @organization = organization | |||
| @new_name = new_name | |||
| @new_identifier = new_identifier | |||
| end | |||
| def call | |||
| @@ -15,11 +17,13 @@ class Projects::ForkService < ApplicationService | |||
| :rep_identifier, :project_category_id, :project_language_id, | |||
| :license_id, :ignore_id, {repository: [:identifier, :hidden]}] | |||
| result = Gitea::Repository::ForkService.new(@project.owner, @target_owner, @project.identifier, @organization).call | |||
| result = Gitea::Repository::ForkService.new(@project.owner, @target_owner, @project.identifier, @organization, @new_identifier).call | |||
| clone_project.owner = @target_owner | |||
| clone_project.forked_from_project_id = @project.id | |||
| clone_project.gpid = result['id'] | |||
| clone_project.name = @new_name if @new_name.present? | |||
| clone_project.identifier = @new_identifier if @new_identifier.present? | |||
| clone_project.save! | |||
| new_repository = clone_project.repository | |||
| @@ -9,7 +9,6 @@ class Projects::MigrateService < ApplicationService | |||
| def call | |||
| raise Error, "user_id不正确." unless authroize_user_id_success | |||
| @project = Project.new(project_params) | |||
| if @project.save! | |||
| ProjectUnit.init_types(@project.id, project.project_type) | |||
| @@ -55,6 +54,7 @@ class Projects::MigrateService < ApplicationService | |||
| user_id: params[:user_id], | |||
| login: params[:auth_username], | |||
| password: params[:auth_password], | |||
| auth_token: params[:auth_token], | |||
| is_mirror: params[:is_mirror], | |||
| source_clone_url: params[:source_clone_url] | |||
| } | |||
| @@ -32,7 +32,8 @@ class Repositories::MigrateService < ApplicationService | |||
| private: params[:hidden], | |||
| mirror: wrapper_mirror || false, | |||
| auth_username: params[:login], | |||
| auth_password: Base64.decode64(params[:password] || "") | |||
| auth_password: Base64.decode64(params[:password] || ""), | |||
| auth_token: params[:auth_token] | |||
| } | |||
| end | |||
| @@ -4,6 +4,7 @@ json.issue_versions @project_versions | |||
| json.issue_priories @project_priories | |||
| json.project_author @project.owner.try(:show_real_name) | |||
| json.project_name @project.try(:name) | |||
| json.disable_pr_vew @project.pr_view_admin? && !@project.manager?(current_user) | |||
| json.members do | |||
| json.array! @project_members.to_a.each do |user| | |||
| json.id user.id | |||
| @@ -10,6 +10,7 @@ json.project_name @project.name | |||
| json.project_author @project.owner.try(:login) | |||
| json.project_author_name @project.owner.try(:show_real_name) | |||
| json.has_created_pull_requests @project.pull_requests.size > 0 | |||
| json.disable_pr_vew @project.pr_view_admin? && !@project.manager?(current_user) | |||
| json.issues do | |||
| json.array! @issues.to_a do |issue| | |||
| @@ -16,5 +16,5 @@ $gitea_hat_client = Gitea::Api::Hat::Client.new({ | |||
| hat_base_url: gitea_config[:hat_base_url], | |||
| username: gitea_config[:access_key_id], | |||
| password: gitea_config[:access_key_secret], | |||
| log_filepath: "log/gitea-client.log" | |||
| log_filepath: "log/gitea-hat-client.log" | |||
| }) | |||
| @@ -15,7 +15,7 @@ namespace :batch_forked_project do | |||
| user = User.find_by(login: username) | |||
| next if user.blank? | |||
| next if Project.exists?(user_id: user.id, identifier: project.identifier) | |||
| new_project = Projects::ForkService.new(user, project, nil).call | |||
| new_project = Projects::ForkService.new(user, project, nil, nil, nil).call | |||
| random_num = rand(5..20) | |||
| members = user_logins.sample(random_num) | |||
| members.each do |m| | |||
| @@ -4,7 +4,7 @@ | |||
| namespace :init_project_topic do | |||
| desc "Init Project Topic for Project" | |||
| task project: :environment do | |||
| Project.order(created_at: :desc).find_each do |p| | |||
| Project.where(platform: 'forge').order(created_at: :desc).find_each do |p| | |||
| next unless p.owner.present? | |||
| next if p.project_topics.size >= 3 | |||
| begin | |||