forked from Gitlink/forgeplus
Merge branch 'develop' into dev_trustie_server
This commit is contained in:
commit
299e8534d1
|
@ -86,3 +86,4 @@ redis_data/
|
|||
Dockerfile
|
||||
dump.rdb
|
||||
.tags*
|
||||
ceshi_user.xlsx
|
|
@ -774,7 +774,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def convert_image!
|
||||
@image = params[:image] || user_params[:image]
|
||||
@image = params[:image]
|
||||
@image = @image.nil? && params[:user].present? ? params[:user][:image] : @image
|
||||
return unless @image.present?
|
||||
max_size = EduSetting.get('upload_avatar_max_size') || 2 * 1024 * 1024 # 2M
|
||||
if @image.class == ActionDispatch::Http::UploadedFile
|
||||
|
|
|
@ -302,9 +302,11 @@ class IssuesController < ApplicationController
|
|||
# update_hash = params[:issue]
|
||||
issue_ids = params[:ids]
|
||||
if issue_ids.present?
|
||||
issues = Issue.where(id: issue_ids)
|
||||
if update_hash.blank?
|
||||
normal_status(-1, "请选择批量更新内容")
|
||||
elsif Issue.where(id: issue_ids)&.update(update_hash)
|
||||
elsif issues&.update(update_hash)
|
||||
issues.map{|i| i.create_journal_detail(false, [], [], current_user&.id) if i.previous_changes.present?}
|
||||
normal_status(0, "批量更新成功")
|
||||
else
|
||||
normal_status(-1, "批量更新失败")
|
||||
|
|
|
@ -16,6 +16,7 @@ class ProjectsController < ApplicationController
|
|||
menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code")
|
||||
menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues")
|
||||
menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
|
||||
menu.append(menu_hash_by_name("wiki")) if @project.has_menu_permission("wiki")
|
||||
menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
|
||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
||||
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources")
|
||||
|
|
|
@ -34,11 +34,12 @@ module ProjectsHelper
|
|||
end
|
||||
|
||||
def json_response(project, user)
|
||||
repo = Repository.includes(:mirror).select(:id, :mirror_url, :source_clone_url).find_by(project: project)
|
||||
repo = Repository.includes(:mirror).select(:id, :is_mirror, :mirror_url, :source_clone_url).find_by(project: project)
|
||||
|
||||
tmp_json = {}
|
||||
unless project.common?
|
||||
tmp_json = tmp_json.merge({
|
||||
is_mirror: repo.is_mirror ? true : false,
|
||||
mirror_status: repo.mirror_status,
|
||||
mirror_num: repo.mirror_num,
|
||||
mirror_url: repo.remote_mirror_url,
|
||||
|
@ -54,7 +55,11 @@ module ProjectsHelper
|
|||
repo_id: repo.id,
|
||||
open_devops: (user.blank? || user.is_a?(AnonymousUser)) ? false : project.open_devops?,
|
||||
type: project.numerical_for_project_type,
|
||||
author: render_owner(project)
|
||||
author: render_owner(project),
|
||||
project_category_id: project.project_category_id,
|
||||
project_language_id: project.project_language_id,
|
||||
license_id: project.license_id,
|
||||
ignore_id: project.ignore_id
|
||||
}).compact
|
||||
|
||||
render json: tmp_json
|
||||
|
|
|
@ -8,10 +8,13 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
|||
puts "############ MigrateRemoteRepositoryJob starting ... ############"
|
||||
|
||||
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
|
||||
if gitea_repository
|
||||
repo&.project&.update_columns(gpid: gitea_repository["id"])
|
||||
puts "#gitea_repository#{gitea_repository}"
|
||||
if gitea_repository[0]==201
|
||||
repo&.project&.update_columns(gpid: gitea_repository[2]["id"])
|
||||
repo&.mirror&.succeeded!
|
||||
puts "############ mirror status: #{repo.mirror.status} ############"
|
||||
else
|
||||
repo&.mirror&.failed!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
class ProjectUnit < ApplicationRecord
|
||||
belongs_to :project
|
||||
|
||||
enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5, resources: 6}
|
||||
enum unit_type: {code: 1, issues: 2, pulls: 3, wiki:4, devops: 5, versions: 6, resources: 7}
|
||||
|
||||
validates :unit_type, uniqueness: { scope: :project_id}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Gitea::Repository::MigrateService < Gitea::ClientService
|
|||
def call
|
||||
response = post(url, request_params)
|
||||
|
||||
render_201_response(response)
|
||||
render_response(response)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,7 +8,7 @@ json.user_login @version.version_user.try(:login)
|
|||
json.created_at format_time(@version.created_on)
|
||||
json.updated_at format_time(@version.updated_on)
|
||||
json.search_count @version_issues_size
|
||||
json.percent @version.percent*100
|
||||
json.percent @version_close_issues_size.to_f/@version_issues_size*100#@version.percent*100
|
||||
json.extract! @version, :id,:name,:project_id,:description, :effective_date, :status, :sharing,:wiki_page_title
|
||||
|
||||
json.issues do
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
namespace :produce_and_export_ceshi_user do
|
||||
desc "Produce ceshi user and Export to excel"
|
||||
task call: :environment do
|
||||
puts "=======Begin======="
|
||||
DCODES = %W(1 2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
|
||||
username = DCODES.sample(8).join
|
||||
email = username + '@forge.com'
|
||||
password = SecureRandom.base64[8..-1]
|
||||
p = Axlsx::Package.new
|
||||
p.workbook.add_worksheet(:name => '测试用户') do |sheet|
|
||||
sheet.add_row ["用户名", "邮箱", "密码", "GiteaToken", "测试仓库", "测试仓库克隆地址"]
|
||||
(1..100).to_a.each do |i|
|
||||
while (User.find_by(login: username).present? || User.find_by(mail: email).present?) do
|
||||
username = DCODES.sample(8).join
|
||||
email = username + '@forge.com'
|
||||
password = SecureRandom.base64[8..-1]
|
||||
end
|
||||
puts "=======Generate:[#{i}] Username: #{username}, Password: #{password}, Email: #{email}======="
|
||||
puts "=======Create User Begin====== "
|
||||
|
||||
user = User.new(admin: false, login: username, mail: email, type: "User")
|
||||
user.password = password
|
||||
user.platform = 'forge'
|
||||
user.activate
|
||||
|
||||
next unless user.valid?
|
||||
|
||||
interactor = Gitea::RegisterInteractor.call({username: username, email: email, password: password})
|
||||
if interactor.success?
|
||||
gitea_user = interactor.result
|
||||
result = Gitea::User::GenerateTokenService.call(username, password)
|
||||
user.gitea_token = result['sha1']
|
||||
user.gitea_uid = gitea_user[:body]['id']
|
||||
if user.save!
|
||||
UserExtension.create!(user_id: user.id)
|
||||
end
|
||||
end
|
||||
|
||||
puts "=======Create User End====== "
|
||||
code = DCODES.sample(8).join
|
||||
project_params = {
|
||||
user_id: user.id,
|
||||
name: code,
|
||||
repository_name: code,
|
||||
project_category_id: ProjectCategory.pluck(:id).sample,
|
||||
project_language_id: ProjectLanguage.pluck(:id).sample,
|
||||
license_id: License.pluck(:id).sample,
|
||||
ignore_id: Ignore.pluck(:id).sample,
|
||||
private: true
|
||||
}
|
||||
project = Projects::CreateService.new(user, project_params).call
|
||||
puts project.as_json
|
||||
sheet.add_row [username, email, password, user.gitea_token, "#{username}/#{code}", project&.repository.url]
|
||||
end
|
||||
end
|
||||
p.use_shared_strings = true
|
||||
p.serialize('ceshi_user.xlsx')
|
||||
|
||||
puts "=======END======="
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue