forked from Gitlink/forgeplus
Compare commits
152 Commits
master
...
dev_edu_lo
| Author | SHA1 | Date |
|---|---|---|
|
|
4494cbe3a9 | |
|
|
a1b18c07df | |
|
|
32ac61d889 | |
|
|
229885f42c | |
|
|
263636126b | |
|
|
35e11bf375 | |
|
|
69efc69e2d | |
|
|
ace13abe92 | |
|
|
de2b54c39e | |
|
|
4929734a1a | |
|
|
1c6d8fc2f3 | |
|
|
d271a684fa | |
|
|
e8da6364d8 | |
|
|
34c3a83df4 | |
|
|
71e039efb8 | |
|
|
9ac21938e6 | |
|
|
fa8594d2ab | |
|
|
a7e20dcae2 | |
|
|
06e24a8ea4 | |
|
|
070df3c9dd | |
|
|
3614f3e15b | |
|
|
0bb45c7359 | |
|
|
6aa7a3a3b2 | |
|
|
7c0bc5d444 | |
|
|
334c0c2c09 | |
|
|
113f8ded36 | |
|
|
0178c8b913 | |
|
|
dc07042e83 | |
|
|
6ebab1be66 | |
|
|
27f510e6c9 | |
|
|
d9a27b7728 | |
|
|
68f1d7f7f6 | |
|
|
7e3517d873 | |
|
|
e76d475fef | |
|
|
877ef54b24 | |
|
|
133eed6afe | |
|
|
eba2df5a2d | |
|
|
1392024657 | |
|
|
312fca7e2b | |
|
|
d1939116a3 | |
|
|
2a72fc56a4 | |
|
|
87049b74ef | |
|
|
f19219a467 | |
|
|
4cc46f4cb4 | |
|
|
8331d849d5 | |
|
|
0e7f3a8905 | |
|
|
85a37fdbcc | |
|
|
01341d4389 | |
|
|
a62b29a263 | |
|
|
3a475a4674 | |
|
|
0eccafcb69 | |
|
|
0dbed862a7 | |
|
|
7b27ed71ca | |
|
|
6c3c1ce093 | |
|
|
62d1a2378c | |
|
|
e111f40c69 | |
|
|
8d300e11f9 | |
|
|
b7dd12927b | |
|
|
4126ea7b4e | |
|
|
539b832af6 | |
|
|
0bfed83bc0 | |
|
|
ce8527359c | |
|
|
fff21a1bc8 | |
|
|
526920f564 | |
|
|
2d37df1c00 | |
|
|
0af08bc967 | |
|
|
ea82a52b7b | |
|
|
dfc998a9cc | |
|
|
62bd331876 | |
|
|
91e142ba82 | |
|
|
a82b13ecdf | |
|
|
855c51a470 | |
|
|
8be4bc823c | |
|
|
7af6d8d754 | |
|
|
5a8dc9d5e7 | |
|
|
ecdb79ee48 | |
|
|
50e0ad9804 | |
|
|
953d6790d0 | |
|
|
136d1c1abd | |
|
|
e085ef374b | |
|
|
a557139ad0 | |
|
|
6d0ac60d5a | |
|
|
dda1868a72 | |
|
|
93a1a08393 | |
|
|
4d4d8d1369 | |
|
|
ab42fb7476 | |
|
|
11ac2f9c9d | |
|
|
8a9c3df2e5 | |
|
|
e90f80255e | |
|
|
1b6c082480 | |
|
|
ce1152cd4f | |
|
|
c8a9094ad0 | |
|
|
569088d846 | |
|
|
6159cda155 | |
|
|
d738ea432b | |
|
|
4a30e8c83f | |
|
|
b3288937c9 | |
|
|
7520fa03c2 | |
|
|
f282d971e3 | |
|
|
56f01801ae | |
|
|
45e70367d5 | |
|
|
a0b376e70a | |
|
|
d62d757c42 | |
|
|
033c2607e2 | |
|
|
0d6abdf7d0 | |
|
|
22c68f4c70 | |
|
|
fcd86fb01b | |
|
|
faecb99136 | |
|
|
15a002f601 | |
|
|
206d7bc159 | |
|
|
5e0006a830 | |
|
|
3abf993463 | |
|
|
efbf6d627d | |
|
|
6836907146 | |
|
|
6c4058cde5 | |
|
|
5a2e17abe2 | |
|
|
9a8b89bcd8 | |
|
|
4856da1607 | |
|
|
883a5f7e38 | |
|
|
1658c1b923 | |
|
|
74f6a54d29 | |
|
|
adb315521e | |
|
|
01cad866b8 | |
|
|
3447b17cdf | |
|
|
0079255e98 | |
|
|
490bff5ded | |
|
|
008b8ac709 | |
|
|
d0532a8f70 | |
|
|
a8c4cde350 | |
|
|
5de5974102 | |
|
|
3d3e778078 | |
|
|
f5ea8dc4a2 | |
|
|
c4b942a5f2 | |
|
|
13391b189a | |
|
|
b116a72ce7 | |
|
|
f01aec94d6 | |
|
|
cc97f85a1e | |
|
|
133995080a | |
|
|
27304c35dc | |
|
|
d6bf85ef73 | |
|
|
be9c01bf1d | |
|
|
edeaaa5db7 | |
|
|
0e41b6cc9b | |
|
|
5f3946f187 | |
|
|
b7be00f3ec | |
|
|
9b21e29426 | |
|
|
f37fccfdb3 | |
|
|
810d2dbac6 | |
|
|
6af97d865f | |
|
|
efba4b2b4f | |
|
|
aaf1f43cc2 | |
|
|
823c99bd71 |
|
|
@ -6,6 +6,20 @@ class AccountsController < ApplicationController
|
||||||
render json: session
|
render json: session
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 为了同步平台上未注册gitea的用户
|
||||||
|
def gitea_register
|
||||||
|
user = User.find_by(login: sync_gitea_params[:login])
|
||||||
|
Users::SyncGiteaForm.new(sync_gitea_params.merge(user: user)).validate!
|
||||||
|
return render_error("该用户已同步协作平台") if user.gitea_token.present? && user.gitea_uid.present?
|
||||||
|
|
||||||
|
result = create_gitea_user!(user, sync_gitea_params[:login], sync_gitea_params[:email], sync_gitea_params[:password])
|
||||||
|
|
||||||
|
result[:user] ? render_ok : render_error(result[:message])
|
||||||
|
rescue Exception => e
|
||||||
|
uid_logger_error(e.message)
|
||||||
|
tip_exception(-1, e.message)
|
||||||
|
end
|
||||||
|
|
||||||
# 其他平台同步注册的用户
|
# 其他平台同步注册的用户
|
||||||
def remote_register
|
def remote_register
|
||||||
username = params[:username]&.gsub(/\s+/, "")
|
username = params[:username]&.gsub(/\s+/, "")
|
||||||
|
|
@ -361,6 +375,10 @@ class AccountsController < ApplicationController
|
||||||
{ login: pre + code, email: email, phone: phone }
|
{ login: pre + code, email: email, phone: phone }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync_gitea_params
|
||||||
|
params.permit(:login, :email, :password)
|
||||||
|
end
|
||||||
|
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:login, :email, :phone)
|
params.require(:user).permit(:login, :email, :phone)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -771,7 +771,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
request.base_url
|
Rails.application.config_for(:configuration)['platform_url'] || request.base_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_image!
|
def convert_image!
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,45 @@ class CompareController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
load_compare_params
|
||||||
compare
|
compare
|
||||||
|
@merge_status, @merge_message = get_merge_message
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def get_merge_message
|
||||||
|
if @base.blank? || @head.blank?
|
||||||
|
return -2, "请选择分支"
|
||||||
|
else
|
||||||
|
if @head.include?(":")
|
||||||
|
fork_project = @project.forked_projects.joins(:owner).where(users: {login: @head.to_s.split("/")[0]}).take
|
||||||
|
return -2, "请选择正确的仓库" unless fork_project.present?
|
||||||
|
@exist_pullrequest = @project.pull_requests.where(is_original: true, head: @head.to_s.split(":")[1], base: @base, status: 0, fork_project_id: fork_project.id).take
|
||||||
|
else
|
||||||
|
@exist_pullrequest = @project.pull_requests.where(is_original: false, head: @base, base: @head, status: 0).take
|
||||||
|
end
|
||||||
|
if @exist_pullrequest.present?
|
||||||
|
return -2, "在这些分支之间的合并请求已存在:<a href='/projects/#{@owner.login}/#{@project.identifier}/pulls/#{@exist_pullrequest.id}/Messagecount'>#{@exist_pullrequest.try(:title)}</a>"
|
||||||
|
else
|
||||||
|
if @compare_result["Commits"].blank? && @compare_result["Diff"].blank?
|
||||||
|
return -2, "分支内容相同,无需创建合并请求"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0, "可以合并"
|
||||||
|
end
|
||||||
|
|
||||||
def compare
|
def compare
|
||||||
base, head = compare_params
|
|
||||||
|
|
||||||
# TODO: 处理fork的项目向源项目发送PR的base、head参数问题
|
# TODO: 处理fork的项目向源项目发送PR的base、head参数问题
|
||||||
@compare_result ||=
|
@compare_result ||=
|
||||||
head.include?(":") ? gitea_compare(base, head) : gitea_compare(head, base)
|
@head.include?(":") ? gitea_compare(@base, @head) : gitea_compare(@head, @base)
|
||||||
end
|
end
|
||||||
|
|
||||||
def compare_params
|
def load_compare_params
|
||||||
base = Addressable::URI.unescape(params[:base])
|
@base = Addressable::URI.unescape(params[:base])
|
||||||
head = params[:head].include?('json') ? params[:head]&.split('.json')[0] : params[:head]
|
@head = params[:head].include?('json') ? params[:head]&.split('.json')[0] : params[:head]
|
||||||
|
|
||||||
[base, head]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def gitea_compare(base, head)
|
def gitea_compare(base, head)
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,16 @@ module LaboratoryHelper
|
||||||
# my_projects: "/users/#{current_user.try(:login)}/projects",
|
# my_projects: "/users/#{current_user.try(:login)}/projects",
|
||||||
# my_projects: "https://www.trustie.net/users/#{current_user.try(:login)}/user_projectlist",
|
# my_projects: "https://www.trustie.net/users/#{current_user.try(:login)}/user_projectlist",
|
||||||
{
|
{
|
||||||
new_syllabuses: "https://www.trustie.net/syllabuses/new",
|
new_syllabuses: "https://forge.educoder.net/syllabuses/new",
|
||||||
new_course: "https://www.trustie.net/courses/new",
|
new_course: "https://forge.educoder.net/courses/new",
|
||||||
edit_account: "https://www.trustie.net/my/account",
|
edit_account: "https://forge.educoder.net/my/account",
|
||||||
my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist",
|
my_courses: "https://forge.educoder.net/users/#{current_user.try(:login)}/user_courselist",
|
||||||
my_projects: "/users/#{current_user.try(:login)}/projects",
|
my_projects: "/users/#{current_user.try(:login)}/projects",
|
||||||
my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations",
|
my_organ: "https://forge.educoder.net/users/#{current_user.try(:login)}/user_organizations",
|
||||||
default_url: "https://www.trustie.net/",
|
default_url: "http://106.75.178.228",
|
||||||
tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages",
|
forge_url: "http://106.75.178.228:81",
|
||||||
register_url: "https://www.trustie.net/login?login=false"
|
tiding_url: "https://www.educoder.net/users/#{current_user.try(:login)}/user_tidings",
|
||||||
|
register_url: "https://www.educoder.net/user/register"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ module RegisterHelper
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def autologin_register(username, email, password, platform= 'forge')
|
def autologin_register(username, email, password, platform= 'forge')
|
||||||
result = {message: nil, user: nil}
|
|
||||||
|
|
||||||
user = User.new(admin: false, login: username, mail: email, type: "User")
|
user = User.new(admin: false, login: username, mail: email, type: "User")
|
||||||
user.password = password
|
user.password = password
|
||||||
user.platform = platform
|
user.platform = platform
|
||||||
|
|
@ -11,20 +9,32 @@ module RegisterHelper
|
||||||
|
|
||||||
return unless user.valid?
|
return unless user.valid?
|
||||||
|
|
||||||
|
create_gitea_user!(user, username, email, password)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_gitea_user!(forge_user, username, email, password=random_password)
|
||||||
|
result = {message: nil, user: nil}
|
||||||
|
|
||||||
interactor = Gitea::RegisterInteractor.call({username: username, email: email, password: password})
|
interactor = Gitea::RegisterInteractor.call({username: username, email: email, password: password})
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
gitea_user = interactor.result
|
gitea_user = interactor.result
|
||||||
|
Rails.logger.info "##### [gitea] create_gitea_user result: #{gitea_user}"
|
||||||
result = Gitea::User::GenerateTokenService.call(username, password)
|
result = Gitea::User::GenerateTokenService.call(username, password)
|
||||||
user.gitea_token = result['sha1']
|
forge_user.gitea_token = result['sha1']
|
||||||
user.gitea_uid = gitea_user[:body]['id']
|
forge_user.gitea_uid = gitea_user[:body]['id']
|
||||||
if user.save!
|
forge_user.mail = email
|
||||||
UserExtension.create!(user_id: user.id)
|
if forge_user.save
|
||||||
result[:user] = {id: user.id, token: user.gitea_token}
|
UserExtension.create!(user_id: forge_user.id) if forge_user.user_extension.blank?
|
||||||
|
result[:user] = {id: forge_user.id, token: forge_user.gitea_token}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Rails.logger.info "##### [gitea] create_gitea_user result: #{interactor.error}"
|
||||||
result[:message] = interactor.error
|
result[:message] = interactor.error
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def random_password
|
||||||
|
"#{Random.rand(11111111)}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,14 @@ class ForksController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@new_project = Projects::ForkService.new(current_user, @project, params[:organization]).call
|
@new_project = Projects::ForkService.new(current_user, @project, params[:organization]).call
|
||||||
|
|
||||||
|
# TODO: fix Educoder shixun
|
||||||
|
if @new_project.persisted?
|
||||||
|
ProjectScore.create(:project_id => @new_project.id, :score => 0) if @new_project.project_score.nil?
|
||||||
|
|
||||||
|
project_info = ProjectInfo.new(:user_id => current_user.id, :project_id => @new_project.id)
|
||||||
|
@project.project_infos << project_info
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ class IssuesController < ApplicationController
|
||||||
before_action :load_project
|
before_action :load_project
|
||||||
before_action :set_user
|
before_action :set_user
|
||||||
before_action :check_issue_permission
|
before_action :check_issue_permission
|
||||||
|
before_action :operate_issue_permission, only:[:create, :update, :destroy, :clean, :series_update, :copy]
|
||||||
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
|
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
|
||||||
|
|
||||||
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
|
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
|
||||||
|
|
@ -230,7 +231,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user_permission = current_user.present? && current_user.logged? && (!@issue.is_lock || @project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
||||||
@issue_attachments = @issue.attachments
|
@issue_attachments = @issue.attachments
|
||||||
@issue_user = @issue.user
|
@issue_user = @issue.user
|
||||||
@issue_assign_to = @issue.get_assign_user
|
@issue_assign_to = @issue.get_assign_user
|
||||||
|
|
@ -303,7 +304,7 @@ class IssuesController < ApplicationController
|
||||||
if issue_ids.present?
|
if issue_ids.present?
|
||||||
if update_hash.blank?
|
if update_hash.blank?
|
||||||
normal_status(-1, "请选择批量更新内容")
|
normal_status(-1, "请选择批量更新内容")
|
||||||
elsif Issue.where(id: issue_ids).update_all(update_hash)
|
elsif Issue.where(id: issue_ids)&.update(update_hash)
|
||||||
normal_status(0, "批量更新成功")
|
normal_status(0, "批量更新成功")
|
||||||
else
|
else
|
||||||
normal_status(-1, "批量更新失败")
|
normal_status(-1, "批量更新失败")
|
||||||
|
|
@ -315,6 +316,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def copy
|
def copy
|
||||||
@new_issue = @issue.dup
|
@new_issue = @issue.dup
|
||||||
|
@new_issue.author_id = current_user.id
|
||||||
if @new_issue.save
|
if @new_issue.save
|
||||||
issue_tags = @issue.issue_tags.pluck(:id)
|
issue_tags = @issue.issue_tags.pluck(:id)
|
||||||
if issue_tags.present?
|
if issue_tags.present?
|
||||||
|
|
@ -412,6 +414,10 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def operate_issue_permission
|
||||||
|
return render_forbidden("您没有权限进行此操作.") unless current_user.admin? || @project.member?(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
def export_issues(issues)
|
def export_issues(issues)
|
||||||
@table_columns = %w(ID 类型 标题 描述 状态 指派给 优先级 标签 发布人 创建时间 里程碑 开始时间 截止时间 完成度 分类 金额 属于)
|
@table_columns = %w(ID 类型 标题 描述 状态 指派给 优先级 标签 发布人 创建时间 里程碑 开始时间 截止时间 完成度 分类 金额 属于)
|
||||||
@export_issues = []
|
@export_issues = []
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,14 @@ class MainController < ApplicationController
|
||||||
uid_logger("main start is #{cookies[:_educoder_session]}")
|
uid_logger("main start is #{cookies[:_educoder_session]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:path] && params[:path].start_with?('projects/')
|
||||||
|
project_id = params[:path].split("/")[1]
|
||||||
|
project = Project.find_by_id(project_id)
|
||||||
|
if project.present?
|
||||||
|
return redirect_to("/projects/#{project.owner.login}/#{project.identifier}", status: 301)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: 这块之后需要整合,者架构重新变化,统一跳转到index后再路由分发
|
# TODO: 这块之后需要整合,者架构重新变化,统一跳转到index后再路由分发
|
||||||
if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild"
|
if params[:path] && params[:path]&.include?("h5educoderbuild") && params[:path].split("/").first == "h5educoderbuild"
|
||||||
render file: 'public/h5educoderbuild/index.html', :layout => false
|
render file: 'public/h5educoderbuild/index.html', :layout => false
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,16 @@ class MembersController < ApplicationController
|
||||||
before_action :check_member_not_exists!, only: %i[remove change_role]
|
before_action :check_member_not_exists!, only: %i[remove change_role]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
if @user.gitea_token.blank?
|
||||||
|
result = Gitea::User::GetService.call(@user.login)
|
||||||
|
if result[:status] == :error
|
||||||
|
# gitea不存在用户@user,直接注册
|
||||||
|
user_result = create_gitea_user!(@user, @user.login, @user.mail)
|
||||||
|
return render_error(user_result[:message]) if user_result[:message]
|
||||||
|
end
|
||||||
|
end
|
||||||
interactor = Projects::AddMemberInteractor.call(@project.owner, @project, @user)
|
interactor = Projects::AddMemberInteractor.call(@project.owner, @project, @user)
|
||||||
|
|
||||||
render_response(interactor)
|
render_response(interactor)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
uid_logger_error(e.message)
|
uid_logger_error(e.message)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class ProjectsController < ApplicationController
|
||||||
include Acceleratorable
|
include Acceleratorable
|
||||||
|
|
||||||
before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users recommend about menu_list]
|
before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users recommend about menu_list]
|
||||||
before_action :load_project, except: %i[index group_type_list migrate create recommend]
|
before_action :load_repository, except: %i[index group_type_list migrate create recommend]
|
||||||
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
||||||
before_action :project_public?, only: %i[fork_users praise_users watch_users]
|
before_action :project_public?, only: %i[fork_users praise_users watch_users]
|
||||||
|
|
||||||
|
|
@ -20,6 +20,8 @@ class ProjectsController < ApplicationController
|
||||||
menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
|
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")
|
menu.append(menu_hash_by_name("resources")) if @project.has_menu_permission("resources")
|
||||||
menu.append(menu_hash_by_name("activity"))
|
menu.append(menu_hash_by_name("activity"))
|
||||||
|
menu.append(menu_hash_by_name("gantt"))
|
||||||
|
menu.append(menu_hash_by_name("sonar"))
|
||||||
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
menu.append(menu_hash_by_name("setting")) if current_user.admin? || @project.manager?(current_user)
|
||||||
|
|
||||||
render json: menu
|
render json: menu
|
||||||
|
|
@ -47,6 +49,13 @@ class ProjectsController < ApplicationController
|
||||||
Projects::CreateForm.new(project_params).validate!
|
Projects::CreateForm.new(project_params).validate!
|
||||||
@project = Projects::CreateService.new(current_user, project_params).call
|
@project = Projects::CreateService.new(current_user, project_params).call
|
||||||
|
|
||||||
|
# TODO: fix Educoder shixun
|
||||||
|
if @project.persisted?
|
||||||
|
ProjectScore.create(:project_id => @project.id, :score => 0) if @project.project_score.nil?
|
||||||
|
|
||||||
|
project_info = ProjectInfo.new(:user_id => current_user.id, :project_id => @project.id)
|
||||||
|
@project.project_infos << project_info
|
||||||
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
uid_logger_error(e.message)
|
uid_logger_error(e.message)
|
||||||
|
|
@ -116,10 +125,11 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
Projects::UpdateForm.new(validate_params).validate!
|
Projects::UpdateForm.new(validate_params).validate!
|
||||||
|
|
||||||
private = params[:private] || false
|
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)
|
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||||
@project.update_attributes!(new_project_params)
|
@project.update_attributes!(new_project_params)
|
||||||
|
@project.forked_projects.update_all(is_public: @project.is_public)
|
||||||
gitea_params = {
|
gitea_params = {
|
||||||
private: private,
|
private: private,
|
||||||
default_branch: @project.default_branch,
|
default_branch: @project.default_branch,
|
||||||
|
|
@ -144,6 +154,7 @@ class ProjectsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
||||||
@project.destroy!
|
@project.destroy!
|
||||||
|
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class PullRequestsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
||||||
if @gitea_pull_request[:status] == :success
|
if @gitea_pull_request[:status] == :success
|
||||||
@pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"])
|
@pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"])
|
||||||
render_ok
|
render_ok
|
||||||
else
|
else
|
||||||
render_error("create pull request error: #{@gitea_pull_request[:status]}")
|
render_error("create pull request error: #{@gitea_pull_request[:status]}")
|
||||||
|
|
@ -91,7 +91,7 @@ class PullRequestsController < ApplicationController
|
||||||
if @issue.update_attributes(@issue_params)
|
if @issue.update_attributes(@issue_params)
|
||||||
if @pull_request.update_attributes(@local_params.compact)
|
if @pull_request.update_attributes(@local_params.compact)
|
||||||
gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier,
|
gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier,
|
||||||
@pull_request.gpid, @requests_params, current_user.gitea_token)
|
@pull_request.gitea_number, @requests_params, current_user.gitea_token)
|
||||||
|
|
||||||
if gitea_pull[:status] === :success
|
if gitea_pull[:status] === :success
|
||||||
if params[:issue_tag_ids].present?
|
if params[:issue_tag_ids].present?
|
||||||
|
|
@ -139,7 +139,7 @@ class PullRequestsController < ApplicationController
|
||||||
@issue_user = @issue.user
|
@issue_user = @issue.user
|
||||||
@issue_assign_to = @issue.get_assign_user
|
@issue_assign_to = @issue.get_assign_user
|
||||||
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login,
|
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login,
|
||||||
@repository.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@repository.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pr_merge
|
def pr_merge
|
||||||
|
|
@ -150,9 +150,16 @@ class PullRequestsController < ApplicationController
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
begin
|
begin
|
||||||
result = PullRequests::MergeService.call(@owner, @repository, @pull_request, current_user, params)
|
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login, @repository.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
|
|
||||||
if result.status == 200 && @pull_request.merge!
|
if @gitea_pull["merged_by"].present?
|
||||||
|
success_condition = true
|
||||||
|
else
|
||||||
|
result = PullRequests::MergeService.call(@owner, @repository, @pull_request, current_user, params)
|
||||||
|
success_condition = result.status == 200
|
||||||
|
end
|
||||||
|
|
||||||
|
if success_condition && @pull_request.merge!
|
||||||
@pull_request.project_trend_status!
|
@pull_request.project_trend_status!
|
||||||
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
||||||
normal_status(1, "合并成功")
|
normal_status(1, "合并成功")
|
||||||
|
|
@ -191,12 +198,12 @@ class PullRequestsController < ApplicationController
|
||||||
|
|
||||||
|
|
||||||
def files
|
def files
|
||||||
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
# render json: @files_result
|
# render json: @files_result
|
||||||
end
|
end
|
||||||
|
|
||||||
def commits
|
def commits
|
||||||
@commits_result = Gitea::PullRequest::CommitsService.call(@owner.login, @project.identifier, @pull_request.gpid, current_user&.gitea_token)
|
@commits_result = Gitea::PullRequest::CommitsService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
# render json: @commits_result
|
# render json: @commits_result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ class RepositoriesController < ApplicationController
|
||||||
|
|
||||||
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
||||||
before_action :load_repository
|
before_action :load_repository
|
||||||
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
|
before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive]
|
||||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||||
before_action :get_ref, only: %i[entries sub_entries top_counts file]
|
before_action :get_ref, only: %i[entries sub_entries top_counts file archive]
|
||||||
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
|
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
|
||||||
before_action :get_statistics, only: %i[top_counts]
|
before_action :get_statistics, only: %i[top_counts]
|
||||||
|
|
||||||
|
|
@ -192,6 +192,64 @@ class RepositoriesController < ApplicationController
|
||||||
render json: languages_precentagable
|
render json: languages_precentagable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def archive
|
||||||
|
domain = Gitea.gitea_config[:domain]
|
||||||
|
api_url = Gitea.gitea_config[:base_url]
|
||||||
|
archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{params[:archive]}"
|
||||||
|
|
||||||
|
file_path = [domain, api_url, archive_url].join
|
||||||
|
file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("?") if @repository.hidden?
|
||||||
|
|
||||||
|
return render_not_found if !request.format.zip? && !request.format.gzip?
|
||||||
|
|
||||||
|
redirect_to file_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def sonarqube
|
||||||
|
@sonarqubes = @project.sonarqubes
|
||||||
|
|
||||||
|
branches = Gitea::Repository::Branches::ListService.call(@owner, @project.identifier)
|
||||||
|
branches.each do |branch|
|
||||||
|
sonarqube = @sonarqubes.find_by(branch_name: branch['name'])
|
||||||
|
file_num = 0
|
||||||
|
|
||||||
|
entries = Gitea::Repository::Entries::ListService.call(@owner, @project.identifier, ref: branch['name'])
|
||||||
|
file_num += entries.size
|
||||||
|
entries.each do |entry|
|
||||||
|
file_path_uri = URI.parse(URI.encode(entry['path'].to_s.strip))
|
||||||
|
|
||||||
|
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: branch['name'])
|
||||||
|
if interactor.success?
|
||||||
|
result = interactor.result
|
||||||
|
|
||||||
|
while result.is_a?(Array)
|
||||||
|
file_num += result.size
|
||||||
|
result.each do |res|
|
||||||
|
file_path_uri = URI.parse(URI.encode(res['path'].to_s.strip))
|
||||||
|
interactor = Repositories::EntriesInteractor.call(@owner, @project.identifier, file_path_uri, ref: branch['name'])
|
||||||
|
result = interactor.result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if sonarqube
|
||||||
|
sonarqube.update(bug_num: 0, loophole: 0, repetition_rate: 0, file_num: file_num, created_at: Time.now)
|
||||||
|
sleep 3.seconds
|
||||||
|
sonarqube.update_column(:updated_at, Time.now)
|
||||||
|
else
|
||||||
|
@project.sonarqubes.create!(
|
||||||
|
branch_name: branch['name'],
|
||||||
|
bug_num: 0,
|
||||||
|
loophole: 0,
|
||||||
|
repetition_rate: 0,
|
||||||
|
file_num: file_num
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
|
|
@ -266,7 +324,7 @@ class RepositoriesController < ApplicationController
|
||||||
|
|
||||||
# uploadPushInfo
|
# uploadPushInfo
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_new_pr(params)
|
def create_new_pr(params)
|
||||||
if params[:new_branch].present? && params[:new_branch] != params[:branch]
|
if params[:new_branch].present? && params[:new_branch] != params[:branch]
|
||||||
local_params = {
|
local_params = {
|
||||||
|
|
@ -303,7 +361,7 @@ class RepositoriesController < ApplicationController
|
||||||
local_requests = PullRequest.new(local_params.merge(user_id: current_user.try(:id), project_id: @project.id, issue_id: @pull_issue.id))
|
local_requests = PullRequest.new(local_params.merge(user_id: current_user.try(:id), project_id: @project.id, issue_id: @pull_issue.id))
|
||||||
if local_requests.save
|
if local_requests.save
|
||||||
gitea_request = Gitea::PullRequest::CreateService.new(current_user.try(:gitea_token), @owner.login, @project.try(:identifier), requests_params).call
|
gitea_request = Gitea::PullRequest::CreateService.new(current_user.try(:gitea_token), @owner.login, @project.try(:identifier), requests_params).call
|
||||||
if gitea_request[:status] == :success && local_requests.update_attributes(gpid: gitea_request["body"]["number"])
|
if gitea_request[:status] == :success && local_requests.update_attributes(gitea_number: gitea_request["body"]["number"])
|
||||||
local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
|
local_requests.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users, :hovercard]
|
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users, :hovercard]
|
||||||
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users, :hovercard]
|
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users, :hovercard]
|
||||||
before_action :require_login, only: %i[me list sync_user_info]
|
before_action :require_login, only: %i[me list]
|
||||||
before_action :connect_to_ci_db, only: [:get_user_info]
|
before_action :connect_to_ci_db, only: [:get_user_info]
|
||||||
before_action :convert_image!, only: [:update]
|
before_action :convert_image!, only: [:update]
|
||||||
skip_before_action :check_sign, only: [:attachment_show]
|
skip_before_action :check_sign, only: [:attachment_show]
|
||||||
|
|
@ -254,23 +254,58 @@ class UsersController < ApplicationController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_user_info
|
# TODO: For Educoder
|
||||||
|
def change_password
|
||||||
user = User.find_by_login params[:login]
|
user = User.find_by_login params[:login]
|
||||||
return render_forbidden unless user === current_user
|
|
||||||
|
form_params= {
|
||||||
|
login: params[:login],
|
||||||
|
email: user&.mail,
|
||||||
|
password: params[:password],
|
||||||
|
user: user
|
||||||
|
}
|
||||||
|
Gitea::User::ChangePasswordForm.new(form_params).validate!
|
||||||
|
|
||||||
sync_params = {
|
sync_params = {
|
||||||
email: params[:email],
|
email: user&.mail,
|
||||||
password: params[:password]
|
password: params[:password]
|
||||||
}
|
}
|
||||||
|
|
||||||
Users::UpdateInfoForm.new(sync_params.merge(login: params[:login])).validate!
|
if sync_params.present?
|
||||||
|
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||||
|
if interactor.success?
|
||||||
|
user.update!(password: params[:password], is_sync_pwd: true)
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error(interactor.error)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
# TODO: For Educoder
|
||||||
if interactor.success?
|
def change_email
|
||||||
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_EDIT_INFO)
|
user = User.find_by_login params[:login]
|
||||||
render_ok
|
|
||||||
else
|
form_params= {
|
||||||
render_error(interactor.error)
|
login: params[:login],
|
||||||
|
email: user&.mail,
|
||||||
|
user: user
|
||||||
|
}
|
||||||
|
|
||||||
|
Gitea::User::ChangeEmailForm.new(form_params).validate!
|
||||||
|
|
||||||
|
sync_params = {
|
||||||
|
email: params[:email]
|
||||||
|
}
|
||||||
|
|
||||||
|
if sync_params.present?
|
||||||
|
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||||
|
if interactor.success?
|
||||||
|
user.update!(mail: params[:email])
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error(interactor.error)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,13 @@ class VersionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
version_issues = @version.issues.issue_includes
|
version_issues = @version.issues.issue_issue.issue_includes
|
||||||
|
|
||||||
status_type = params[:status_type] || "1"
|
status_type = params[:status_type] || "1"
|
||||||
# @close_issues_size = version_issues.where(status_id: 5).size
|
# @close_issues_size = version_issues.where(status_id: 5).size
|
||||||
# @open_issues_size = version_issues.size - @close_issues_size
|
# @open_issues_size = version_issues.size - @close_issues_size
|
||||||
|
|
||||||
if status_type.to_s == "1" #表示开启中的
|
|
||||||
version_issues = version_issues.where.not(status_id: 5)
|
|
||||||
else
|
|
||||||
version_issues = version_issues.where(status_id: 5)
|
|
||||||
end
|
|
||||||
version_issues = version_issues.where(author_id: params[:author_id]) if params[:author_id].present? && params[:author_id].to_s != "all"
|
version_issues = version_issues.where(author_id: params[:author_id]) if params[:author_id].present? && params[:author_id].to_s != "all"
|
||||||
version_issues = version_issues.where(assigned_to_id: params[:assigned_to_id]) if params[:assigned_to_id].present? && params[:assigned_to_id].to_s != "all"
|
version_issues = version_issues.where(assigned_to_id: params[:assigned_to_id]) if params[:assigned_to_id].present? && params[:assigned_to_id].to_s != "all"
|
||||||
version_issues = version_issues.where(tracker_id: params[:tracker_id]) if params[:tracker_id].present? && params[:tracker_id].to_s != "all"
|
version_issues = version_issues.where(tracker_id: params[:tracker_id]) if params[:tracker_id].present? && params[:tracker_id].to_s != "all"
|
||||||
|
|
@ -47,10 +43,26 @@ class VersionsController < ApplicationController
|
||||||
version_issues = version_issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].to_i}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all"
|
version_issues = version_issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].to_i}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all"
|
||||||
|
|
||||||
version_issues = version_issues.reorder("#{order_name} #{order_type}")
|
version_issues = version_issues.reorder("#{order_name} #{order_type}")
|
||||||
|
has_filter_params = (params[:author_id].present? && params[:author_id].to_s != "all") ||
|
||||||
|
(params[:assigned_to_id].present? && params[:assigned_to_id].to_s != "all") ||
|
||||||
|
(params[:tracker_id].present? && params[:tracker_id].to_s != "all") ||
|
||||||
|
(params[:status_id].present? && params[:status_id].to_s != "all") ||
|
||||||
|
(params[:priority_id].present? && params[:priority_id].to_s != "all") ||
|
||||||
|
(params[:fixed_version_id].present? && params[:fixed_version_id].to_s != "all") ||
|
||||||
|
(params[:done_ratio].present? && params[:done_ratio].to_s != "all") ||
|
||||||
|
(params[:issue_type].present? && params[:issue_type].to_s != "all") ||
|
||||||
|
(params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all")
|
||||||
|
@version_close_issues_size = has_filter_params ? version_issues.closed.size : @version.issues.issue_issue.issue_includes.closed.size
|
||||||
|
@version_issues_size = has_filter_params ? version_issues.size : @version.issues.issue_issue.issue_includes.size
|
||||||
|
if status_type.to_s == "1" #表示开启中的
|
||||||
|
version_issues = version_issues.where.not(status_id: 5)
|
||||||
|
else
|
||||||
|
version_issues = version_issues.where(status_id: 5)
|
||||||
|
end
|
||||||
|
|
||||||
@page = params[:page] || 1
|
@page = params[:page] || 1
|
||||||
@limit = params[:limit] || 15
|
@limit = params[:limit] || 15
|
||||||
@version_issues_size = version_issues.size
|
# @version_issues_size = version_issues.size
|
||||||
@version_issues = version_issues.page(@page).per(@limit)
|
@version_issues = version_issues.page(@page).per(@limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
class Gitea::User::ChangeEmailForm
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :user
|
||||||
|
attr_accessor :email, :login
|
||||||
|
|
||||||
|
validates :email, presence: true, format: { with: CustomRegexp::EMAIL }
|
||||||
|
validates :login, presence: true
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
class Gitea::User::ChangePasswordForm
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :user
|
||||||
|
attr_accessor :email, :login, :password
|
||||||
|
|
||||||
|
validates :email, presence: true, format: { with: CustomRegexp::EMAIL }
|
||||||
|
validates :login, presence: true
|
||||||
|
validates :password, presence: true
|
||||||
|
|
||||||
|
# validate :check_old_password
|
||||||
|
|
||||||
|
def check_old_password
|
||||||
|
return if user.check_password?(old_password.to_s)
|
||||||
|
|
||||||
|
errors.add(:old_password, :password_error)
|
||||||
|
end
|
||||||
|
|
||||||
|
# def check_user!
|
||||||
|
# user === current_user
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
class Users::SyncGiteaForm
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :login, :password, :email, :user
|
||||||
|
|
||||||
|
validates :login, :password, :email, presence: true
|
||||||
|
|
||||||
|
validate :check_user, :check_password
|
||||||
|
|
||||||
|
def check_user
|
||||||
|
user = User.find_by(login: login)
|
||||||
|
raise '用户不存在.' unless user.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_password
|
||||||
|
raise '用户密码错误.' unless user.check_password?(password)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -13,12 +13,12 @@ module ProjectsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_zip_url(project, archive_name)
|
def render_zip_url(owner, repository, archive)
|
||||||
[gitea_domain, project.owner.login, project.identifier, "archive", "#{archive_name}.zip"].join('/')
|
[base_url, archive_repositories_path(owner&.login, repository, "#{archive}.zip")].join
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_tar_url(project, archive_name)
|
def render_tar_url(owner, repository, archive)
|
||||||
[gitea_domain, project.owner.login, project.identifier, "archive", "#{archive_name}.tar.gz"].join('/')
|
[base_url, archive_repositories_path(owner&.login, repository, "#{archive}.tar.gz")].join
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_http_url(project)
|
def render_http_url(project)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ module RepositoriesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_type?(str)
|
def image_type?(str)
|
||||||
default_type = %w(png jpg gif tif psd svg)
|
default_type = %w(png jpg gif tif psd svg gif bmp webp jpeg)
|
||||||
default_type.include?(str&.downcase)
|
default_type.include?(str&.downcase)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -86,4 +86,39 @@ module RepositoriesHelper
|
||||||
render_decode64_content(entry['content'])
|
render_decode64_content(entry['content'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def base64_to_image(path, content)
|
||||||
|
# generate to https://git.trusite.net/pawm36ozq/-/raw/branch/master/entrn.png"
|
||||||
|
content = Base64.decode64(content)
|
||||||
|
File.open(path, 'wb') { |f| f.write(content) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_download_image_url(dir_path, file_path, content)
|
||||||
|
# 用户名/项目标识/文件路径
|
||||||
|
dir_path = generate_dir_path(dir_path)
|
||||||
|
|
||||||
|
file_path = [dir_path, file_path].join('/')
|
||||||
|
|
||||||
|
puts "##### render_download_image_url file_path: #{file_path}"
|
||||||
|
base64_to_image(file_path, content)
|
||||||
|
|
||||||
|
file_path = file_path.split('public')[1]
|
||||||
|
File.join(base_url, file_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_dir_path(dir_path)
|
||||||
|
# tmp_dir_path
|
||||||
|
# eg: jasder/forgeplus/raw/branch/ref
|
||||||
|
dir_path = ["public", tmp_dir, dir_path].join('/')
|
||||||
|
puts "#### dir_path: #{dir_path}"
|
||||||
|
unless Dir.exists?(dir_path)
|
||||||
|
FileUtils.mkdir_p(dir_path) ##不成功这里会抛异常
|
||||||
|
end
|
||||||
|
dir_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def tmp_dir
|
||||||
|
"repo"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,14 @@ module Gitea
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Contents::CreateForm.new(valid_params).validate!
|
Contents::CreateForm.new(valid_params).validate!
|
||||||
response = Gitea::Repository::Entries::CreateService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call
|
result = Gitea::Repository::Entries::CreateService.call(token,
|
||||||
render_result(response)
|
owner, @params[:identifier], @params[:filepath], file_params)
|
||||||
|
|
||||||
|
if result[:status] == :success
|
||||||
|
@result = result[:body]
|
||||||
|
else
|
||||||
|
fail!(result[:message])
|
||||||
|
end
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
Rails.logger.info "Exception ===========> #{exception.message}"
|
Rails.logger.info "Exception ===========> #{exception.message}"
|
||||||
fail!(exception.message)
|
fail!(exception.message)
|
||||||
|
|
@ -56,7 +62,7 @@ module Gitea
|
||||||
file_params = {}
|
file_params = {}
|
||||||
file_params = file_params.merge(branch: @params[:branch]) unless @params[:branch].blank?
|
file_params = file_params.merge(branch: @params[:branch]) unless @params[:branch].blank?
|
||||||
file_params = file_params.merge(new_branch: @params[:new_branch]) unless @params[:new_branch].blank?
|
file_params = file_params.merge(new_branch: @params[:new_branch]) unless @params[:new_branch].blank?
|
||||||
file_params = file_params.merge(content: Base64.encode64(@params[:content]))
|
file_params = file_params.merge(content: Base64.encode64(@params[:content] || ""))
|
||||||
file_params = file_params.merge(message: @params[:message]) unless @params[:message].blank?
|
file_params = file_params.merge(message: @params[:message]) unless @params[:message].blank?
|
||||||
file_params = file_params.merge(committer: @params[:committer])
|
file_params = file_params.merge(committer: @params[:committer])
|
||||||
file_params
|
file_params
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,17 @@ module Gitea
|
||||||
def run
|
def run
|
||||||
Gitea::UserForm.new(params).validate!
|
Gitea::UserForm.new(params).validate!
|
||||||
response = Gitea::User::RegisterService.call(params.merge(token: token))
|
response = Gitea::User::RegisterService.call(params.merge(token: token))
|
||||||
render_result(response)
|
|
||||||
|
if response[:status] == :success
|
||||||
|
@result = response
|
||||||
|
else
|
||||||
|
fail!(response[:message])
|
||||||
|
end
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
Rails.logger.info "Exception ===========> #{exception.message}"
|
Rails.logger.info "Exception ===========> #{exception.message}"
|
||||||
fail!(exception.message)
|
fail!(exception.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
@ -38,10 +42,6 @@ module Gitea
|
||||||
@error = error
|
@error = error
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_result(response)
|
|
||||||
@result = response
|
|
||||||
end
|
|
||||||
|
|
||||||
def token
|
def token
|
||||||
{
|
{
|
||||||
username: Gitea.gitea_config[:access_key_id],
|
username: Gitea.gitea_config[:access_key_id],
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ class ResetUserCacheJob < ApplicationJob
|
||||||
queue_as :cache
|
queue_as :cache
|
||||||
|
|
||||||
def perform(user)
|
def perform(user)
|
||||||
|
return if user.nil?
|
||||||
Cache::UserFollowCountService.new(user).reset
|
Cache::UserFollowCountService.new(user).reset
|
||||||
Cache::UserIssueCountService.new(user).reset
|
Cache::UserIssueCountService.new(user).reset
|
||||||
Cache::UserProjectCountService.new(user).reset
|
Cache::UserProjectCountService.new(user).reset
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,26 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: applied_messages
|
# Table name: forge_applied_messages
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# applied_id :integer
|
|
||||||
# applied_type :string(255)
|
# applied_type :string(255)
|
||||||
|
# applied_id :integer
|
||||||
# viewed :integer default("0")
|
# viewed :integer default("0")
|
||||||
# status :integer default("0")
|
# status :integer default("0")
|
||||||
# created_at :datetime not null
|
|
||||||
# updated_at :datetime not null
|
|
||||||
# name :string(255)
|
# name :string(255)
|
||||||
# applied_user_id :integer
|
# applied_user_id :integer
|
||||||
# role :integer
|
# role :integer
|
||||||
# project_id :integer
|
# project_id :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forge_applied_messages_on_applied_type_and_applied_id (applied_type,applied_id)
|
||||||
|
# index_forge_applied_messages_on_applied_user_id (applied_user_id)
|
||||||
|
# index_forge_applied_messages_on_project_id (project_id)
|
||||||
|
# index_forge_applied_messages_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class AppliedMessage < ApplicationRecord
|
class AppliedMessage < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,19 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: applied_projects
|
# Table name: forge_applied_projects
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# project_id :integer not null
|
# project_id :integer
|
||||||
# user_id :integer not null
|
# user_id :integer
|
||||||
# role :integer default("0")
|
# role :integer default("0")
|
||||||
# status :integer default("0")
|
# status :integer default("0")
|
||||||
# created_at :datetime
|
# created_at :datetime not null
|
||||||
# updated_at :datetime
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_forge_applied_projects_on_project_id (project_id)
|
||||||
|
# index_forge_applied_projects_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class AppliedProject < ApplicationRecord
|
class AppliedProject < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,42 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: attachments
|
# Table name: attachments
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# container_id :integer
|
# container_id :integer
|
||||||
# container_type :string(30)
|
# container_type :string(30)
|
||||||
# filename :string(255) default(""), not null
|
# filename :string(255) default(""), not null
|
||||||
# disk_filename :string(255) default(""), not null
|
# disk_filename :string(255) default(""), not null
|
||||||
# filesize :integer default("0"), not null
|
# filesize :integer default("0"), not null
|
||||||
# content_type :string(255) default("")
|
# content_type :string(255) default("")
|
||||||
# digest :string(60) default(""), not null
|
# digest :string(60) default(""), not null
|
||||||
# downloads :integer default("0"), not null
|
# downloads :integer default("0"), not null
|
||||||
# author_id :integer default("0"), not null
|
# author_id :integer default("0"), not null
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# description :text(65535)
|
# description :text(65535)
|
||||||
# disk_directory :string(255)
|
# disk_directory :string(255)
|
||||||
# attachtype :integer default("1")
|
# attachtype :integer default("1")
|
||||||
# is_public :integer default("1")
|
# is_public :integer default("1")
|
||||||
# copy_from :integer
|
# copy_from :string(255)
|
||||||
# quotes :integer default("0")
|
# quotes :integer default("0")
|
||||||
# is_publish :integer default("1")
|
# is_publish :integer default("1")
|
||||||
# publish_time :datetime
|
# publish_time :datetime
|
||||||
# resource_bank_id :integer
|
# resource_bank_id :integer
|
||||||
# unified_setting :boolean default("1")
|
# unified_setting :boolean default("1")
|
||||||
# cloud_url :string(255) default("")
|
# cloud_url :string(255) default("")
|
||||||
# course_second_category_id :integer default("0")
|
# course_second_category_id :integer default("0")
|
||||||
# delay_publish :boolean default("0")
|
# delay_publish :boolean default("0")
|
||||||
#
|
# link :string(255)
|
||||||
# Indexes
|
# clone_id :integer
|
||||||
#
|
#
|
||||||
# index_attachments_on_author_id (author_id)
|
# Indexes
|
||||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
#
|
||||||
# index_attachments_on_course_second_category_id (course_second_category_id)
|
# index_attachments_on_author_id (author_id)
|
||||||
# index_attachments_on_created_on (created_on)
|
# index_attachments_on_clone_id (clone_id)
|
||||||
# index_attachments_on_is_public (is_public)
|
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||||
# index_attachments_on_quotes (quotes)
|
# index_attachments_on_created_on (created_on)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Attachment < ApplicationRecord
|
class Attachment < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ module ProjectOperable
|
||||||
if owner.is_a?(User)
|
if owner.is_a?(User)
|
||||||
managers.exists?(user_id: user.id)
|
managers.exists?(user_id: user.id)
|
||||||
elsif owner.is_a?(Organization)
|
elsif owner.is_a?(Organization)
|
||||||
managers.exists?(user_id: user.id) || owner.is_only_admin?(user.id)
|
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || owner.is_only_admin?(user.id)
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
@ -94,7 +94,7 @@ module ProjectOperable
|
||||||
end
|
end
|
||||||
|
|
||||||
def operator?(user)
|
def operator?(user)
|
||||||
user.admin? || !reporter?(user)
|
user.admin? || (member?(user.id) && !reporter?(user))
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_developer_role(member, role_name)
|
def set_developer_role(member, role_name)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
class Gitea::Base < Gitea::Database
|
class Gitea::Base < ApplicationRecord
|
||||||
self.abstract_class = true
|
db_config = Rails.configuration.database_configuration[Rails.env]["gitea_server"]
|
||||||
|
raise 'gitea database config missing' if db_config.blank?
|
||||||
|
|
||||||
|
establish_connection db_config
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: pull_request
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# type :integer
|
||||||
|
# status :integer
|
||||||
|
# conflicted_files :text(65535)
|
||||||
|
# commits_ahead :integer
|
||||||
|
# commits_behind :integer
|
||||||
|
# changed_protected_files :text(65535)
|
||||||
|
# issue_id :integer
|
||||||
|
# index :integer
|
||||||
|
# head_repo_id :integer
|
||||||
|
# base_repo_id :integer
|
||||||
|
# head_branch :string(255)
|
||||||
|
# base_branch :string(255)
|
||||||
|
# merge_base :string(40)
|
||||||
|
# has_merged :boolean
|
||||||
|
# merged_commit_id :string(40)
|
||||||
|
# merger_id :integer
|
||||||
|
# merged_unix :integer
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# IDX_pull_request_base_repo_id (base_repo_id)
|
||||||
|
# IDX_pull_request_has_merged (has_merged)
|
||||||
|
# IDX_pull_request_head_repo_id (head_repo_id)
|
||||||
|
# IDX_pull_request_issue_id (issue_id)
|
||||||
|
# IDX_pull_request_merged_unix (merged_unix)
|
||||||
|
# IDX_pull_request_merger_id (merger_id)
|
||||||
|
#
|
||||||
|
|
||||||
|
class Gitea::Pull < Gitea::Base
|
||||||
|
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
|
||||||
|
# establish_connection :gitea_db
|
||||||
|
|
||||||
|
self.table_name = "pull_request"
|
||||||
|
|
||||||
|
serialize :conflicted_files, Array
|
||||||
|
|
||||||
|
belongs_to :pull_request, class_name: '::PullRequest', foreign_key: :id, primary_key: :gitea_id, optional: true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
# sync_course :boolean default("0")
|
# sync_course :boolean default("0")
|
||||||
# sync_subject :boolean default("0")
|
# sync_subject :boolean default("0")
|
||||||
# sync_shixun :boolean default("0")
|
# sync_shixun :boolean default("0")
|
||||||
|
# is_local :boolean default("0")
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
# content :text(65535)
|
# content :text(65535)
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# is_secret :boolean default("0")
|
|
||||||
#
|
#
|
||||||
|
|
||||||
class License < ApplicationRecord
|
class License < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
# course_group_id :integer default("0")
|
# course_group_id :integer default("0")
|
||||||
# is_collect :integer default("1")
|
# is_collect :integer default("1")
|
||||||
# graduation_group_id :integer default("0")
|
# graduation_group_id :integer default("0")
|
||||||
# is_apply_signature :boolean default("0")
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,78 +1,80 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: projects
|
# Table name: projects
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255) default(""), not null
|
# name :string(255) default(""), not null
|
||||||
# description :text(4294967295)
|
# description :text(4294967295)
|
||||||
# homepage :string(255) default("")
|
# homepage :string(255) default("")
|
||||||
# is_public :boolean default("1"), not null
|
# is_public :boolean default("1"), not null
|
||||||
# parent_id :integer
|
# parent_id :integer
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# updated_on :datetime
|
# updated_on :datetime
|
||||||
# identifier :string(255)
|
# identifier :string(255)
|
||||||
# status :integer default("1"), not null
|
# status :integer default("1"), not null
|
||||||
# lft :integer
|
# lft :integer
|
||||||
# rgt :integer
|
# rgt :integer
|
||||||
# inherit_members :boolean default("0"), not null
|
# inherit_members :boolean default("0"), not null
|
||||||
# project_type :integer default("0")
|
# project_type :integer default("0")
|
||||||
# hidden_repo :boolean default("0"), not null
|
# hidden_repo :boolean default("0"), not null
|
||||||
# attachmenttype :integer default("1")
|
# attachmenttype :integer default("1")
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# dts_test :integer default("0")
|
# dts_test :integer default("0")
|
||||||
# enterprise_name :string(255)
|
# enterprise_name :string(255)
|
||||||
# organization_id :integer
|
# organization_id :integer
|
||||||
# project_new_type :integer
|
# project_new_type :integer
|
||||||
# gpid :integer
|
# gpid :integer
|
||||||
# forked_from_project_id :integer
|
# forked_from_project_id :integer
|
||||||
# forked_count :integer default("0")
|
# forked_count :integer default("0")
|
||||||
# publish_resource :integer default("0")
|
# publish_resource :integer default("0")
|
||||||
# visits :integer default("0")
|
# visits :integer default("0")
|
||||||
# hot :integer default("0")
|
# hot :integer default("0")
|
||||||
# invite_code :string(255)
|
# invite_code :string(255)
|
||||||
# qrcode :string(255)
|
# qrcode :string(255)
|
||||||
# qrcode_expiretime :integer default("0")
|
# qrcode_expiretime :integer default("0")
|
||||||
# script :text(65535)
|
# script :text(65535)
|
||||||
# training_status :integer default("0")
|
# training_status :integer default("0")
|
||||||
# rep_identifier :string(255)
|
# rep_identifier :string(255)
|
||||||
# project_category_id :integer
|
# project_category_id :integer
|
||||||
# project_language_id :integer
|
# project_language_id :integer
|
||||||
# license_id :integer
|
# praises_count :integer default("0")
|
||||||
# ignore_id :integer
|
# watchers_count :integer default("0")
|
||||||
# praises_count :integer default("0")
|
# issues_count :integer default("0")
|
||||||
# watchers_count :integer default("0")
|
# pull_requests_count :integer default("0")
|
||||||
# issues_count :integer default("0")
|
# language :string(255)
|
||||||
# pull_requests_count :integer default("0")
|
# versions_count :integer default("0")
|
||||||
# language :string(255)
|
# issue_tags_count :integer default("0")
|
||||||
# versions_count :integer default("0")
|
# closed_issues_count :integer default("0")
|
||||||
# issue_tags_count :integer default("0")
|
# open_devops :boolean default("0")
|
||||||
# closed_issues_count :integer default("0")
|
# gitea_webhook_id :integer
|
||||||
# open_devops :boolean default("0")
|
# open_devops_count :integer default("0")
|
||||||
# gitea_webhook_id :integer
|
# recommend :boolean default("0")
|
||||||
# open_devops_count :integer default("0")
|
# platform :integer default("0")
|
||||||
# recommend :boolean default("0")
|
# license_id :integer
|
||||||
# platform :integer default("0")
|
# ignore_id :integer
|
||||||
# default_branch :string(255) default("master")
|
# default_branch :string(255) default("master")
|
||||||
# website :string(255)
|
# website :string(255)
|
||||||
# order_index :integer default("0")
|
# lesson_url :string(255)
|
||||||
# lesson_url :string(255)
|
#
|
||||||
#
|
# Indexes
|
||||||
# Indexes
|
#
|
||||||
#
|
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
# index_projects_on_identifier (identifier)
|
||||||
# index_projects_on_identifier (identifier)
|
# index_projects_on_invite_code (invite_code)
|
||||||
# index_projects_on_invite_code (invite_code)
|
# index_projects_on_is_public (is_public)
|
||||||
# index_projects_on_is_public (is_public)
|
# index_projects_on_lft (lft)
|
||||||
# index_projects_on_lft (lft)
|
# index_projects_on_license_id (license_id)
|
||||||
# index_projects_on_name (name)
|
# index_projects_on_name (name)
|
||||||
# index_projects_on_platform (platform)
|
# index_projects_on_platform (platform)
|
||||||
# index_projects_on_project_type (project_type)
|
# index_projects_on_project_category_id (project_category_id)
|
||||||
# index_projects_on_recommend (recommend)
|
# index_projects_on_project_language_id (project_language_id)
|
||||||
# index_projects_on_rgt (rgt)
|
# index_projects_on_project_type (project_type)
|
||||||
# index_projects_on_status (status)
|
# index_projects_on_recommend (recommend)
|
||||||
# index_projects_on_updated_on (updated_on)
|
# index_projects_on_rgt (rgt)
|
||||||
#
|
# index_projects_on_status (status)
|
||||||
|
# index_projects_on_updated_on (updated_on)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -98,13 +100,16 @@ class Project < ApplicationRecord
|
||||||
belongs_to :organization_extension, foreign_key: :user_id, primary_key: :organization_id, optional: true, counter_cache: :num_projects
|
belongs_to :organization_extension, foreign_key: :user_id, primary_key: :organization_id, optional: true, counter_cache: :num_projects
|
||||||
belongs_to :project_category, optional: true , :counter_cache => true
|
belongs_to :project_category, optional: true , :counter_cache => true
|
||||||
belongs_to :project_language, optional: true , :counter_cache => true
|
belongs_to :project_language, optional: true , :counter_cache => true
|
||||||
|
belongs_to :forked_from_project, class_name: 'Project', optional: true, foreign_key: :forked_from_project_id
|
||||||
has_many :project_trends, dependent: :destroy
|
has_many :project_trends, dependent: :destroy
|
||||||
has_many :watchers, as: :watchable, dependent: :destroy
|
has_many :watchers, as: :watchable, dependent: :destroy
|
||||||
has_many :fork_users, dependent: :destroy
|
has_many :fork_users, dependent: :destroy
|
||||||
has_many :forked_users, class_name: 'ForkUser', foreign_key: :fork_project_id, dependent: :destroy
|
has_many :forked_users, class_name: 'ForkUser', foreign_key: :fork_project_id, dependent: :destroy
|
||||||
|
has_many :forked_projects, class_name: 'Project', foreign_key: :forked_from_project_id
|
||||||
has_one :project_educoder, dependent: :destroy
|
has_one :project_educoder, dependent: :destroy
|
||||||
|
|
||||||
has_one :project_score, dependent: :destroy
|
has_one :project_score, dependent: :destroy
|
||||||
|
has_many :project_infos, :dependent => :destroy
|
||||||
has_one :repository, dependent: :destroy
|
has_one :repository, dependent: :destroy
|
||||||
has_many :pull_requests, dependent: :destroy
|
has_many :pull_requests, dependent: :destroy
|
||||||
has_many :issue_tags, -> { order("issue_tags.created_at DESC") }, dependent: :destroy
|
has_many :issue_tags, -> { order("issue_tags.created_at DESC") }, dependent: :destroy
|
||||||
|
|
@ -120,6 +125,7 @@ class Project < ApplicationRecord
|
||||||
has_one :applied_transfer_project,-> { order created_at: :desc }, dependent: :destroy
|
has_one :applied_transfer_project,-> { order created_at: :desc }, dependent: :destroy
|
||||||
has_many :pinned_projects, dependent: :destroy
|
has_many :pinned_projects, dependent: :destroy
|
||||||
has_many :has_pinned_users, through: :pinned_projects, source: :user
|
has_many :has_pinned_users, through: :pinned_projects, source: :user
|
||||||
|
has_many :sonarqubes, dependent: :destroy
|
||||||
|
|
||||||
after_save :check_project_members, :reset_cache_data
|
after_save :check_project_members, :reset_cache_data
|
||||||
before_save :set_invite_code
|
before_save :set_invite_code
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,6 @@
|
||||||
# projects_count :integer default("0")
|
# projects_count :integer default("0")
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# ancestry :string(255)
|
|
||||||
#
|
|
||||||
# Indexes
|
|
||||||
#
|
|
||||||
# index_project_categories_on_ancestry (ancestry)
|
|
||||||
#
|
#
|
||||||
|
|
||||||
class ProjectCategory < ApplicationRecord
|
class ProjectCategory < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: project_infos
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# project_id :integer
|
||||||
|
# user_id :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
|
||||||
|
class ProjectInfo < ActiveRecord::Base
|
||||||
|
|
||||||
|
belongs_to :project
|
||||||
|
belongs_to :user
|
||||||
|
validates_presence_of :project_id, :user_id
|
||||||
|
validates_uniqueness_of :project_id, :scope => :user_id
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
class ProjectUnit < ApplicationRecord
|
class ProjectUnit < ApplicationRecord
|
||||||
belongs_to :project
|
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, devops: 4, versions: 5, resources: 6, gantt: 7, sonar: 8}
|
||||||
|
|
||||||
validates :unit_type, uniqueness: { scope: :project_id}
|
validates :unit_type, uniqueness: { scope: :project_id}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
# Table name: pull_requests
|
# Table name: pull_requests
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# pull_request_id :integer
|
# gitea_id :integer
|
||||||
# gpid :integer
|
# gitea_number :integer
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
|
@ -37,6 +37,7 @@ class PullRequest < ApplicationRecord
|
||||||
has_many :pull_request_tags, foreign_key: :pull_request_id
|
has_many :pull_request_tags, foreign_key: :pull_request_id
|
||||||
has_many :project_trends, as: :trend, dependent: :destroy
|
has_many :project_trends, as: :trend, dependent: :destroy
|
||||||
has_many :attachments, as: :container, dependent: :destroy
|
has_many :attachments, as: :container, dependent: :destroy
|
||||||
|
has_one :gitea_pull, foreign_key: :id, primary_key: :gitea_id, class_name: 'Gitea::Pull'
|
||||||
|
|
||||||
scope :merged_and_closed, ->{where.not(status: 0)}
|
scope :merged_and_closed, ->{where.not(status: 0)}
|
||||||
scope :opening, -> {where(status: 0)}
|
scope :opening, -> {where(status: 0)}
|
||||||
|
|
@ -53,8 +54,10 @@ class PullRequest < ApplicationRecord
|
||||||
Project.find_by(id: self.fork_project_id)
|
Project.find_by(id: self.fork_project_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_gitea_pull_request!(gitea_pull_number)
|
def bind_gitea_pull_request!(gitea_pull_number, gitea_pull_id)
|
||||||
update_column(:gpid, gitea_pull_number)
|
update_columns(
|
||||||
|
gitea_number: gitea_pull_number,
|
||||||
|
gitea_id: gitea_pull_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge!
|
def merge!
|
||||||
|
|
@ -67,19 +70,26 @@ class PullRequest < ApplicationRecord
|
||||||
|
|
||||||
# TODO: sync educoder platform repo's for update some statistics count
|
# TODO: sync educoder platform repo's for update some statistics count
|
||||||
def self.update_some_count
|
def self.update_some_count
|
||||||
PullRequest.includes(:user, :project).select(:id, :user_id, :gpid, :project_id, :fork_project_id).each do |pr|
|
PullRequest.includes(:user, :project).select(:id, :user_id, :gitea_number, :project_id, :fork_project_id).each do |pr|
|
||||||
puts pr.id
|
puts pr.id
|
||||||
next if pr.gpid.blank?
|
next if pr.gitea_number.blank?
|
||||||
project = pr.project
|
project = pr.project
|
||||||
|
|
||||||
next if project.blank?
|
next if project.blank?
|
||||||
user = project.owner
|
user = project.owner
|
||||||
next if pr.gpid === 6 || pr.gpid === 7
|
next if pr.gitea_number === 6 || pr.gitea_number === 7
|
||||||
files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gpid)
|
files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gitea_number)
|
||||||
pr.update_column(:files_count, files_result['NumFiles']) unless files_result.blank?
|
pr.update_column(:files_count, files_result['NumFiles']) unless files_result.blank?
|
||||||
|
|
||||||
commits_result = Gitea::PullRequest::CommitsService.call(user.login, project.identifier, pr.gpid)
|
commits_result = Gitea::PullRequest::CommitsService.call(user.login, project.identifier, pr.gitea_number)
|
||||||
pr.update_column(:commits_count, commits_result.size) unless commits_result.blank?
|
pr.update_column(:commits_count, commits_result.size) unless commits_result.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conflict_files
|
||||||
|
file_names = self&.gitea_pull&.conflicted_files
|
||||||
|
return [] if file_names.blank?
|
||||||
|
|
||||||
|
JSON.parse file_names
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_repositories_on_identifier (identifier)
|
|
||||||
# index_repositories_on_project_id (project_id)
|
# index_repositories_on_project_id (project_id)
|
||||||
# index_repositories_on_user_id (user_id)
|
# index_repositories_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: sonarqubes
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# loophole :integer default("0")
|
||||||
|
# repetition_rate :integer default("0")
|
||||||
|
# bug_num :integer default("0")
|
||||||
|
# file_num :integer default("0")
|
||||||
|
# project_id :integer
|
||||||
|
# branch_name :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
|
||||||
|
class Sonarqube < ApplicationRecord
|
||||||
|
belongs_to :project, optional: true
|
||||||
|
end
|
||||||
|
|
@ -39,17 +39,15 @@
|
||||||
# business :boolean default("0")
|
# business :boolean default("0")
|
||||||
# profile_completed :boolean default("0")
|
# profile_completed :boolean default("0")
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# platform :string(255) default("0")
|
|
||||||
# gitea_token :string(255)
|
|
||||||
# gitea_uid :integer
|
|
||||||
# is_shixun_marker :boolean default("0")
|
# is_shixun_marker :boolean default("0")
|
||||||
|
# admin_visitable :boolean default("0")
|
||||||
|
# collaborator :boolean default("0")
|
||||||
|
# gitea_uid :integer
|
||||||
# is_sync_pwd :boolean default("1")
|
# is_sync_pwd :boolean default("1")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# devops_step :integer default("0")
|
# devops_step :integer default("0")
|
||||||
# sponsor_certification :integer default("0")
|
# gitea_token :string(255)
|
||||||
# sponsor_num :integer default("0")
|
# platform :string(255)
|
||||||
# sponsored_num :integer default("0")
|
|
||||||
# award_time :datetime
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
@ -57,8 +55,9 @@
|
||||||
# index_users_on_homepage_engineer (homepage_engineer)
|
# index_users_on_homepage_engineer (homepage_engineer)
|
||||||
# index_users_on_homepage_teacher (homepage_teacher)
|
# index_users_on_homepage_teacher (homepage_teacher)
|
||||||
# index_users_on_laboratory_id (laboratory_id)
|
# index_users_on_laboratory_id (laboratory_id)
|
||||||
# index_users_on_login (login)
|
# index_users_on_login (login) UNIQUE
|
||||||
# index_users_on_mail (mail)
|
# index_users_on_mail (mail) UNIQUE
|
||||||
|
# index_users_on_phone (phone) UNIQUE
|
||||||
# index_users_on_type (type)
|
# index_users_on_type (type)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -186,7 +185,7 @@ class User < Owner
|
||||||
:show_email, :show_location, :show_department,
|
:show_email, :show_location, :show_department,
|
||||||
:technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true
|
:technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true
|
||||||
|
|
||||||
before_save :update_hashed_password
|
before_save :update_hashed_password, :set_lastname
|
||||||
after_create do
|
after_create do
|
||||||
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
|
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
|
||||||
end
|
end
|
||||||
|
|
@ -779,6 +778,10 @@ class User < Owner
|
||||||
|
|
||||||
self.laboratory = Laboratory.current if laboratory_id.blank?
|
self.laboratory = Laboratory.current if laboratory_id.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_lastname
|
||||||
|
self.lastname = self.nickname if changes[:nickname].present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_user_actions_on_ip (ip)
|
# index_user_actions_on_ip (ip)
|
||||||
|
# index_user_actions_on_user_id (user_id)
|
||||||
|
# index_user_actions_on_user_id_and_action_type (user_id,action_type)
|
||||||
#
|
#
|
||||||
|
|
||||||
class UserAction < ApplicationRecord
|
class UserAction < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,13 @@
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# register_status :integer default("0")
|
# register_status :integer default("0")
|
||||||
# action_status :integer default("0")
|
# action_status :integer default("0")
|
||||||
|
# is_delete :boolean default("0")
|
||||||
|
# user_id :integer
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_user_agents_on_ip (ip) UNIQUE
|
# index_user_agents_on_ip (ip)
|
||||||
|
# index_user_agents_on_user_id (user_id)
|
||||||
#
|
#
|
||||||
|
|
||||||
class UserAgent < ApplicationRecord
|
class UserAgent < ApplicationRecord
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@
|
||||||
# school_id :integer
|
# school_id :integer
|
||||||
# description :string(255) default("")
|
# description :string(255) default("")
|
||||||
# department_id :integer
|
# department_id :integer
|
||||||
|
# honor :text(65535)
|
||||||
|
# edu_background :integer
|
||||||
|
# edu_entry_year :integer
|
||||||
# province :string(255)
|
# province :string(255)
|
||||||
# city :string(255)
|
# city :string(255)
|
||||||
# custom_department :string(255)
|
# custom_department :string(255)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Version < ApplicationRecord
|
class Version < ApplicationRecord
|
||||||
belongs_to :project, counter_cache: true, touch: true
|
belongs_to :project, counter_cache: true, touch: true, optional: true
|
||||||
has_many :issues, class_name: "Issue", foreign_key: "fixed_version_id"
|
has_many :issues, class_name: "Issue", foreign_key: "fixed_version_id"
|
||||||
belongs_to :user, optional: true
|
belongs_to :user, optional: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,11 @@ class Cache::PlatformProjectLanguagesCountService < ApplicationService
|
||||||
|
|
||||||
def reset_platform_project_language_count_by_key
|
def reset_platform_project_language_count_by_key
|
||||||
return if key.nil?
|
return if key.nil?
|
||||||
$redis_cache.hset(platform_project_language_count_key, key, Project.joins(:project_language).where(project_languages: {name: key}).count)
|
$redis_cache.hset(platform_project_language_count_key, key, ProjectLanguage.where(name: key).projects_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_platform_project_language_count
|
def reset_platform_project_language_count
|
||||||
Project.joins(:project_language).group("project_languages.name").count.each do |k, v|
|
ProjectLanguage.where.not(projects_count: 0).group("project_languages.name").sum(:projects_count).each do |k, v|
|
||||||
$redis_cache.hset(platform_project_language_count_key, k, v)
|
$redis_cache.hset(platform_project_language_count_key, k, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,14 @@ class Gitea::ClientService < ApplicationService
|
||||||
[body, message]
|
[body, message]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def json_parse!(body)
|
||||||
|
return nil unless body.present?
|
||||||
|
|
||||||
|
body = JSON.parse(body)
|
||||||
|
body, message = fix_body(body)
|
||||||
|
body
|
||||||
|
end
|
||||||
|
|
||||||
def log_error(status, body)
|
def log_error(status, body)
|
||||||
puts "[gitea] status: #{status}"
|
puts "[gitea] status: #{status}"
|
||||||
puts "[gitea] body: #{body&.force_encoding('UTF-8')}"
|
puts "[gitea] body: #{body&.force_encoding('UTF-8')}"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::CloseService < Gitea::PullRequest::UpdateService
|
||||||
# number: number of pull request
|
# number: number of pull request
|
||||||
# token: token of gitea user
|
# token: token of gitea user
|
||||||
# eq:
|
# eq:
|
||||||
# Gitea::PullRequest::CloseService.call(owner.login, repo.identifier, pull.gpid, pull.base, current_user.gitea_token)
|
# Gitea::PullRequest::CloseService.call(owner.login, repo.identifier, pull.gitea_number, pull.base, current_user.gitea_token)
|
||||||
def initialize(owner, repo, number, base,token=nil)
|
def initialize(owner, repo, number, base,token=nil)
|
||||||
colse_pull_params = Hash.new.merge(base: base, state: 'closed').compact
|
colse_pull_params = Hash.new.merge(base: base, state: 'closed').compact
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ class Gitea::PullRequest::GetService < Gitea::ClientService
|
||||||
attr_reader :owner, :repo, :number, :token
|
attr_reader :owner, :repo, :number, :token
|
||||||
|
|
||||||
#eq:
|
#eq:
|
||||||
# Gitea::PullRequest::GetService.call(user.login, repository.identifier, pull.gpid, user.gitea_token)
|
# Gitea::PullRequest::GetService.call(user.login, repository.identifier, pull.gitea_number, user.gitea_token)
|
||||||
def initialize(owner, repo, number, token=nil)
|
def initialize(owner, repo, number, token=nil)
|
||||||
@owner = owner
|
@owner = owner
|
||||||
@repo = repo
|
@repo = repo
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::OpenService < Gitea::PullRequest::UpdateService
|
||||||
# number: number of pull request
|
# number: number of pull request
|
||||||
# token: token of gitea user
|
# token: token of gitea user
|
||||||
# eq:
|
# eq:
|
||||||
# Gitea::PullRequest::OpenService.new(owner.login, repo.identifier, pr.gpid, pr.base, current_user.gitea_token)
|
# Gitea::PullRequest::OpenService.new(owner.login, repo.identifier, pr.gitea_number, pr.base, current_user.gitea_token)
|
||||||
def initialize(owner, repo, number, base, token=nil)
|
def initialize(owner, repo, number, base, token=nil)
|
||||||
open_pull_params = Hash.new.merge(base: base, state: 'open').compact
|
open_pull_params = Hash.new.merge(base: base, state: 'open').compact
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
class Gitea::Repository::ArchiveService < Gitea::ClientService
|
||||||
|
attr_reader :owner, :repo, :archive, :token
|
||||||
|
|
||||||
|
def initialize(owner, repo, archive, token=nil)
|
||||||
|
@owner = owner
|
||||||
|
@repo = repo
|
||||||
|
@archive = archive
|
||||||
|
@token = token
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
response = get(url, params)
|
||||||
|
response_payload(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def params
|
||||||
|
Hash.new.merge(token: token)
|
||||||
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
"/repos/#{owner}/#{repo}/archive/#{archive}".freeze
|
||||||
|
end
|
||||||
|
|
||||||
|
def response_payload(response)
|
||||||
|
status = response.status
|
||||||
|
body = response&.body
|
||||||
|
|
||||||
|
log_error(status, body)
|
||||||
|
status_payload(status, body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_payload(status, body)
|
||||||
|
case status
|
||||||
|
when 200 then success
|
||||||
|
when 404 then error("你操作的链接不存在!")
|
||||||
|
else error("系统错误!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -25,8 +25,7 @@ class Gitea::Repository::CreateService < Gitea::ClientService
|
||||||
private
|
private
|
||||||
|
|
||||||
def request_params
|
def request_params
|
||||||
create_params = params.merge(readme: "readme")
|
Hash.new.merge(token: token, data: params)
|
||||||
Hash.new.merge(token: token, data: create_params)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
||||||
|
|
||||||
def call
|
def call
|
||||||
response = post(url, params)
|
response = post(url, params)
|
||||||
|
response_payload(response)
|
||||||
render_201_response(response)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
@ -43,4 +42,21 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
||||||
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".freeze
|
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def response_payload(response)
|
||||||
|
status = response.status
|
||||||
|
body = response&.body
|
||||||
|
|
||||||
|
log_error(status, body)
|
||||||
|
status_payload(status, body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_payload(status, body)
|
||||||
|
case status
|
||||||
|
when 201 then success(json_parse!(body))
|
||||||
|
when 403 then error("你没有权限操作!")
|
||||||
|
when 404 then error("你操作的链接不存在!")
|
||||||
|
when 422 then error("#{filepath}文件已存在,不能重复创建!")
|
||||||
|
else error("系统错误!")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
class Gitea::User::GetService < Gitea::ClientService
|
||||||
|
attr_reader :username
|
||||||
|
# params:
|
||||||
|
# username* string # required
|
||||||
|
def initialize(username)
|
||||||
|
@username = username
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
response = get(url, params)
|
||||||
|
|
||||||
|
status, message, body = render_response(response)
|
||||||
|
json_format(status, message, body)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def url
|
||||||
|
"/users/#{username}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def params
|
||||||
|
{username: username}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def json_format(status, message, body)
|
||||||
|
case status
|
||||||
|
when 200 then success(body)
|
||||||
|
else
|
||||||
|
error(message, status)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,8 +10,7 @@ class Gitea::User::RegisterService < Gitea::ClientService
|
||||||
params = Hash.new.merge(data: user_params, token: @token)
|
params = Hash.new.merge(data: user_params, token: @token)
|
||||||
|
|
||||||
response = post(API_REST, params)
|
response = post(API_REST, params)
|
||||||
status, message, body = render_response(response)
|
response_payload(response)
|
||||||
json_format(status, message, body)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
@ -27,11 +26,28 @@ class Gitea::User::RegisterService < Gitea::ClientService
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def json_format(status, message, body)
|
def response_payload(response)
|
||||||
|
status = response.status
|
||||||
|
body = response&.body
|
||||||
|
|
||||||
|
log_error(status, body)
|
||||||
|
status_payload(status, body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_payload(status, body)
|
||||||
case status
|
case status
|
||||||
when 201 then success(body)
|
when 201 then success(json_parse!(body))
|
||||||
else
|
when 403 then error("你没有权限操作!")
|
||||||
error(message, status)
|
when 400 then error("服务器开小差了")
|
||||||
|
when 422
|
||||||
|
body = json_parse!(body)
|
||||||
|
message = body['message']
|
||||||
|
if message.include?('email')
|
||||||
|
error("邮箱#{email}已被注册")
|
||||||
|
elsif message.include?('name')
|
||||||
|
error("用户名#{username}已被注册")
|
||||||
|
end
|
||||||
|
else error("系统错误!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ class Projects::CreateService < ApplicationService
|
||||||
|
|
||||||
def call
|
def call
|
||||||
Rails.logger.info("#############__________project_params______###########{project_params}")
|
Rails.logger.info("#############__________project_params______###########{project_params}")
|
||||||
|
raise Error, "user_id不正确." unless authroize_user_id_success
|
||||||
|
|
||||||
@project = Project.new(project_params)
|
@project = Project.new(project_params)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
|
@ -27,6 +28,10 @@ class Projects::CreateService < ApplicationService
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def authroize_user_id_success
|
||||||
|
(user.id == params[:user_id].to_i) || (user.organizations.find_by_id(params[:user_id]).present?)
|
||||||
|
end
|
||||||
|
|
||||||
def project_params
|
def project_params
|
||||||
{
|
{
|
||||||
name: params[:name],
|
name: params[:name],
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ class Projects::MigrateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
|
raise Error, "user_id不正确." unless authroize_user_id_success
|
||||||
|
|
||||||
@project = Project.new(project_params)
|
@project = Project.new(project_params)
|
||||||
if @project.save!
|
if @project.save!
|
||||||
ProjectUnit.init_types(@project.id, project.project_type)
|
ProjectUnit.init_types(@project.id, project.project_type)
|
||||||
|
|
@ -24,6 +26,9 @@ class Projects::MigrateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def authroize_user_id_success
|
||||||
|
(user.id == params[:user_id].to_i) || (user.organizations.find_by_id(params[:user_id]).present?)
|
||||||
|
end
|
||||||
|
|
||||||
def project_params
|
def project_params
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class PullRequests::CloseService < ApplicationService
|
||||||
|
|
||||||
def close_gitea_pull
|
def close_gitea_pull
|
||||||
Gitea::PullRequest::CloseService.call(@owner.login, @repo.identifier,
|
Gitea::PullRequest::CloseService.call(@owner.login, @repo.identifier,
|
||||||
@pull.gpid, @pull.base, current_user.gitea_token)
|
@pull.gitea_number, @pull.base, current_user.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pull_status!
|
def update_pull_status!
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class PullRequests::MergeService < ApplicationService
|
||||||
|
|
||||||
def gitea_pull_merge!
|
def gitea_pull_merge!
|
||||||
result = Gitea::PullRequest::MergeService.call(@current_user.gitea_token, @owner.login,
|
result = Gitea::PullRequest::MergeService.call(@current_user.gitea_token, @owner.login,
|
||||||
@repo.identifier, @pull.gpid, gitea_merge_pull_params)
|
@repo.identifier, @pull.gitea_number, gitea_merge_pull_params)
|
||||||
@status, @message = result
|
@status, @message = result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class PullRequests::OpenService < ApplicationService
|
||||||
|
|
||||||
def open_gitea_pull
|
def open_gitea_pull
|
||||||
Gitea::PullRequest::OpenService.call(@owner.login, @repo.identifier,
|
Gitea::PullRequest::OpenService.call(@owner.login, @repo.identifier,
|
||||||
@pull.gpid, @pull.base, @current_user.gitea_token)
|
@pull.gitea_number, @pull.base, @current_user.gitea_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pull_status!
|
def update_pull_status!
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,11 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if school && school.identifier.present? %>
|
<%# if school && school.identifier.present? %>
|
||||||
<% else %>
|
<%#= link_to school.identifier.to_s, statistics_college_path(school.identifier), target: '_blank' %>
|
||||||
|
<%# else %>
|
||||||
--
|
--
|
||||||
<% end %>
|
<%# end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="member-container">
|
<td class="member-container">
|
||||||
<div class="laboratory-user">
|
<div class="laboratory-user">
|
||||||
|
|
@ -29,21 +30,6 @@
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td><%= laboratory.created_at.strftime('%Y-%m-%d %H:%M') %></td>
|
<td><%= laboratory.created_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||||
<td>
|
|
||||||
<% if school.present? && laboratory.id != 1 %>
|
|
||||||
<%= check_box_tag :sync_course,!laboratory.sync_course,laboratory.sync_course,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if school.present? && laboratory.id != 1 %>
|
|
||||||
<%= check_box_tag :sync_subject,!laboratory.sync_subject,laboratory.sync_subject,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if school.present? && laboratory.id != 1 %>
|
|
||||||
<%= check_box_tag :sync_shixun,!laboratory.sync_shixun,laboratory.sync_shixun,remote:true,data:{id:laboratory.id},class:"laboratory-sync-form" %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td class="action-container">
|
<td class="action-container">
|
||||||
<%= link_to '定制', admins_laboratory_laboratory_setting_path(laboratory), class: 'action' %>
|
<%= link_to '定制', admins_laboratory_laboratory_setting_path(laboratory), class: 'action' %>
|
||||||
|
|
||||||
|
|
@ -51,18 +37,4 @@
|
||||||
<%= javascript_void_link '添加管理员', class: 'action', data: { laboratory_id: laboratory.id, toggle: 'modal', target: '.admin-add-laboratory-user-modal' } %>
|
<%= javascript_void_link '添加管理员', class: 'action', data: { laboratory_id: laboratory.id, toggle: 'modal', target: '.admin-add-laboratory-user-modal' } %>
|
||||||
<%= link_to '同步用户', synchronize_user_admins_laboratory_path(laboratory), remote: true, data: { confirm: '确认同步该单位下的所有用户到云上实验室吗?' }, class: 'action' %>
|
<%= link_to '同步用户', synchronize_user_admins_laboratory_path(laboratory), remote: true, data: { confirm: '确认同步该单位下的所有用户到云上实验室吗?' }, class: 'action' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="d-inline">
|
|
||||||
<%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %>
|
|
||||||
<div class="dropdown-menu more-action-dropdown">
|
|
||||||
<%= link_to '轮播图', admins_laboratory_carousels_path(laboratory), class: 'dropdown-item' %>
|
|
||||||
|
|
||||||
<%= link_to '查看实训项目', admins_laboratory_laboratory_shixuns_path(laboratory), class: 'dropdown-item' %>
|
|
||||||
<%= link_to '查看实践课程', admins_laboratory_laboratory_subjects_path(laboratory), class: 'dropdown-item' %>
|
|
||||||
|
|
||||||
<% if school.present? && laboratory.id != 1 %>
|
|
||||||
<%= delete_link '删除', admins_laboratory_path(laboratory, element: ".laboratory-item-#{laboratory.id}"), class: 'dropdown-item delete-laboratory-action' %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@
|
||||||
<th width="6%">统计链接</th>
|
<th width="6%">统计链接</th>
|
||||||
<th width="22%">管理员</th>
|
<th width="22%">管理员</th>
|
||||||
<th width="10%"><%= sort_tag('创建时间', name: 'id', path: admins_laboratories_path) %></th>
|
<th width="10%"><%= sort_tag('创建时间', name: 'id', path: admins_laboratories_path) %></th>
|
||||||
<th width="4%" title="同步显示主站下该单位的课堂">同步课堂</th>
|
|
||||||
<th width="4%" title="同步显示主站下该单位用户创建的实践课程">同步实践课程</th>
|
|
||||||
<th width="4%" title="同步显示主站下该单位用户创建的实训">同步实训</th>
|
|
||||||
<th width="16%">操作</th>
|
<th width="16%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,6 @@
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
|
<%= sidebar_item_group('#setting-submenu', '网站建设', icon: 'cogs') do %>
|
||||||
<li><%= sidebar_item(edit_admins_about_path, '关于我们', icon: 'smile-o', controller: 'admins-abouts') %></li>
|
|
||||||
<li><%= sidebar_item(edit_admins_contact_us_path, '联系我们', icon: 'commenting-o', controller: 'admins-contact_us') %></li>
|
|
||||||
<li><%= sidebar_item(admins_cooperatives_path, '合作伙伴', icon: 'handshake-o', controller: 'admins-cooperatives') %></li>
|
|
||||||
<li><%= sidebar_item(edit_admins_agreement_path, '服务协议', icon: 'file-text-o', controller: 'admins-agreements') %></li>
|
|
||||||
<li><%= sidebar_item(edit_admins_help_center_path, '帮助中心', icon: 'question-circle-o', controller: 'admins-help_centers') %></li>
|
<li><%= sidebar_item(edit_admins_help_center_path, '帮助中心', icon: 'question-circle-o', controller: 'admins-help_centers') %></li>
|
||||||
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %></li>
|
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -83,3 +83,5 @@ json.diff do
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
json.status @merge_status
|
||||||
|
json.message @merge_message
|
||||||
|
|
@ -2,6 +2,6 @@ json.total_count @owners.size
|
||||||
json.owners @owners.each do |owner|
|
json.owners @owners.each do |owner|
|
||||||
json.id owner.id
|
json.id owner.id
|
||||||
json.type owner.type
|
json.type owner.type
|
||||||
json.name owner.login
|
json.name owner&.show_real_name
|
||||||
json.avatar_url url_to_avatar(owner)
|
json.avatar_url url_to_avatar(owner)
|
||||||
end
|
end
|
||||||
|
|
@ -4,8 +4,8 @@ json.array! @branches do |branch|
|
||||||
json.user_can_merge branch['user_can_merge']
|
json.user_can_merge branch['user_can_merge']
|
||||||
json.protected branch['protected']
|
json.protected branch['protected']
|
||||||
json.http_url render_http_url(@project)
|
json.http_url render_http_url(@project)
|
||||||
json.zip_url render_zip_url(@project, branch['name'])
|
json.zip_url render_zip_url(@owner, @repository, branch['name'])
|
||||||
json.tar_url render_tar_url(@project, branch['name'])
|
json.tar_url render_tar_url(@owner, @repository, branch['name'])
|
||||||
json.last_commit do
|
json.last_commit do
|
||||||
json.sha branch['commit']['id']
|
json.sha branch['commit']['id']
|
||||||
json.message branch['commit']['message']
|
json.message branch['commit']['message']
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
json.extract! @project, :id, :name,:identifier
|
json.extract! @project, :id, :name,:identifier
|
||||||
|
json.login @project&.owner&.login
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,5 @@ json.issue do
|
||||||
json.version @issue.version.try(:name)
|
json.version @issue.version.try(:name)
|
||||||
json.issue_tags @issue.get_issue_tags
|
json.issue_tags @issue.get_issue_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
json.conflict_files @pull_request.conflict_files
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,16 @@ if @project.forge?
|
||||||
|
|
||||||
json.content decode64_content(entry, @owner, @repository, @ref)
|
json.content decode64_content(entry, @owner, @repository, @ref)
|
||||||
json.target entry['target']
|
json.target entry['target']
|
||||||
json.download_url entry['download_url']
|
|
||||||
|
download_url =
|
||||||
|
if image_type
|
||||||
|
dir_path = [@owner.login, @repository.identifier, "raw/branch", @ref].join('/')
|
||||||
|
render_download_image_url(dir_path, entry['path'], decode64_content(entry, @owner, @repository, @ref))
|
||||||
|
else
|
||||||
|
entry['download_url']
|
||||||
|
end
|
||||||
|
json.download_url download_url
|
||||||
|
|
||||||
json.direct_download direct_download
|
json.direct_download direct_download
|
||||||
json.image_type image_type
|
json.image_type image_type
|
||||||
json.is_readme_file is_readme?(entry['type'], entry['name'])
|
json.is_readme_file is_readme?(entry['type'], entry['name'])
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,9 @@ if @project.forge?
|
||||||
#json.tags_count @tags_count
|
#json.tags_count @tags_count
|
||||||
#json.branches_count @branches_count
|
#json.branches_count @branches_count
|
||||||
json.commits_count @commits_count
|
json.commits_count @commits_count
|
||||||
json.zip_url render_zip_url(@project, @ref)
|
# json.zip_url archive_repositories_path(@owner&.login, @repository, @ref)
|
||||||
json.tar_url render_tar_url(@project, @ref)
|
json.zip_url render_zip_url(@owner, @repository, @ref)
|
||||||
|
json.tar_url render_tar_url(@owner, @repository, @ref)
|
||||||
json.entries do
|
json.entries do
|
||||||
json.array! @entries do |entry|
|
json.array! @entries do |entry|
|
||||||
json.name entry['name']
|
json.name entry['name']
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
json.array! @sonarqubes do |sonarqube|
|
||||||
|
json.branch_name sonarqube.branch_name
|
||||||
|
json.bug_num sonarqube.bug_num
|
||||||
|
json.loophole sonarqube.loophole
|
||||||
|
json.repetition_rate number_to_percentage(sonarqube.repetition_rate, precision: 1)
|
||||||
|
json.file_num sonarqube.file_num
|
||||||
|
json.created_at format_time(sonarqube.created_at)
|
||||||
|
json.updated_at format_time(sonarqube.updated_at)
|
||||||
|
end
|
||||||
|
|
@ -2,8 +2,8 @@ json.array! @tags do |tag|
|
||||||
if tag.present?
|
if tag.present?
|
||||||
json.name tag['name']
|
json.name tag['name']
|
||||||
json.id tag['id']
|
json.id tag['id']
|
||||||
json.zipball_url tag['zipball_url']
|
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
|
||||||
json.tarball_url tag['tarball_url']
|
json.tarball_url render_tar_url(@owner, @repository, tag['name'])
|
||||||
json.commit do
|
json.commit do
|
||||||
json.sha tag['commit']['sha']
|
json.sha tag['commit']['sha']
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@ json.setting do
|
||||||
|
|
||||||
nav_bar = default_setting.navbar
|
nav_bar = default_setting.navbar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
hash = {hidden: false, link: 'http://106.75.178.228/ecs/department?school_id=1', name: '工程认证'}
|
||||||
|
nav_bar << hash
|
||||||
|
|
||||||
# if User.current.logged?
|
# if User.current.logged?
|
||||||
# nav_bar[2]["link"] = "https://forgeplus.trustie.net/users/#{current_user.login}/projects"
|
# nav_bar[2]["link"] = "https://forgeplus.trustie.net/users/#{current_user.login}/projects"
|
||||||
# nav_bar[2]["hidden"] = false
|
# nav_bar[2]["hidden"] = false
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ json.user_id @user.id
|
||||||
json.image_url url_to_avatar(@user)
|
json.image_url url_to_avatar(@user)
|
||||||
json.admin @user.admin?
|
json.admin @user.admin?
|
||||||
json.is_teacher @user.user_extension&.teacher?
|
json.is_teacher @user.user_extension&.teacher?
|
||||||
|
json.has_gitea_user @user.gitea_token.present? && @user.gitea_uid.present?
|
||||||
|
json.is_sync_pwd @user.is_sync_pwd
|
||||||
json.user_identity @user.identity
|
json.user_identity @user.identity
|
||||||
json.tidding_count 0
|
json.tidding_count 0
|
||||||
json.user_phone_binded @user.phone.present?
|
json.user_phone_binded @user.phone.present?
|
||||||
# json.phone @user.phone
|
# json.phone @user.phone
|
||||||
# json.email @user.mail
|
json.email @user.mail
|
||||||
json.profile_completed @user.profile_completed?
|
json.profile_completed @user.profile_completed?
|
||||||
json.professional_certification @user.professional_certification
|
json.professional_certification @user.professional_certification
|
||||||
json.devops_step @user.devops_step
|
json.devops_step @user.devops_step
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ json.releases do
|
||||||
json.name re["name"]
|
json.name re["name"]
|
||||||
json.body re["body"]
|
json.body re["body"]
|
||||||
json.url re["url"]
|
json.url re["url"]
|
||||||
json.tarball_url re["tarball_url"]
|
json.tarball_url render_tar_url(@owner, @repository, re["tag_name"])
|
||||||
json.zipball_url re["zipball_url"]
|
json.zipball_url render_zip_url(@owner, @repository, re["tag_name"])
|
||||||
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
||||||
json.created_at format_time(version.created_at.to_s.to_time)
|
json.created_at format_time(version.created_at.to_s.to_time)
|
||||||
json.published_at format_time(version.created_at.to_s.to_time)
|
json.published_at format_time(version.created_at.to_s.to_time)
|
||||||
|
|
@ -30,8 +30,8 @@ json.releases do
|
||||||
json.name re["name"]
|
json.name re["name"]
|
||||||
json.body re["body"]
|
json.body re["body"]
|
||||||
json.url re["url"]
|
json.url re["url"]
|
||||||
json.tarball_url re["tarball_url"]
|
json.tarball_url render_tar_url(@owner, @repository, re["tag_name"])
|
||||||
json.zipball_url re["zipball_url"]
|
json.zipball_url render_zip_url(@owner, @repository, re["tag_name"])
|
||||||
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
||||||
json.created_at format_time(version.created_at.to_s.to_time)
|
json.created_at format_time(version.created_at.to_s.to_time)
|
||||||
json.published_at format_time(version.created_at.to_s.to_time)
|
json.published_at format_time(version.created_at.to_s.to_time)
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ json.versions do
|
||||||
|
|
||||||
json.array! @versions.each.to_a do |version|
|
json.array! @versions.each.to_a do |version|
|
||||||
json.extract! version, :id, :name, :description, :effective_date,:status,:percent
|
json.extract! version, :id, :name, :description, :effective_date,:status,:percent
|
||||||
json.open_issues_count (version.issues_count - version.closed_issues_count)
|
json.open_issues_count (version.issues.issue_issue.size - version.issues.issue_issue.closed.size)
|
||||||
json.close_issues_count version.closed_issues_count
|
json.close_issues_count version.issues.issue_issue.closed.size
|
||||||
json.created_at format_time(version.created_on)
|
json.created_at format_time(version.created_on)
|
||||||
json.updated_at format_time(version.updated_on)
|
json.updated_at format_time(version.updated_on)
|
||||||
json.user_name version.version_user.try(:show_real_name)
|
json.user_name version.version_user.try(:show_real_name)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
json.partial! "commons/success"
|
json.partial! "commons/success"
|
||||||
json.issues_count @version.issues_count
|
json.issues_count @version_issues_size
|
||||||
json.open_issues_count @version.issues_count - @version.closed_issues_count
|
json.open_issues_count @version_issues_size - @version_close_issues_size
|
||||||
json.close_issues_count @version.closed_issues_count
|
json.close_issues_count @version_close_issues_size
|
||||||
json.limit @limit
|
json.limit @limit
|
||||||
json.user_name @version.version_user.try(:show_real_name)
|
json.user_name @version.version_user.try(:show_real_name)
|
||||||
json.user_login @version.version_user.try(:login)
|
json.user_login @version.version_user.try(:login)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
default: &default
|
default: &default
|
||||||
# 用户登入的时候设置/登出的时候清空
|
# 用户登入的时候设置/登出的时候清空
|
||||||
autologin_cookie_name: 'autologin_trustie'
|
autologin_cookie_name: 'autologin_trustie'
|
||||||
|
platform_url: 'http://localhost:3000'
|
||||||
|
|
||||||
|
|
||||||
#附件上传路径
|
#附件上传路径
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,13 @@ default: &default
|
||||||
username: root
|
username: root
|
||||||
password: 123456
|
password: 123456
|
||||||
# socket: /var/run/mysqld/mysqld.sock
|
# socket: /var/run/mysqld/mysqld.sock
|
||||||
|
gitea_server:
|
||||||
|
aadapter: mysql2
|
||||||
|
database: gitea_development
|
||||||
|
host: 127.0.0.1
|
||||||
|
username: root
|
||||||
|
password: "123456"
|
||||||
|
encoding: utf8
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
# Rails.application.config.session_store :active_record_store
|
# Rails.application.config.session_store :active_record_store
|
||||||
|
|
||||||
# Be sure to restart your server when you modify this file.
|
# Be sure to restart your server when you modify this file.
|
||||||
Rails.application.config.session_store :cache_store, :expire_after => 24.hours, :httponly => false, :secure => false, key: '_educoder_session', domain: :all
|
Rails.application.config.session_store :cache_store, :expire_after => 24.hours, :httponly => true, :secure => false, key: '_educoder_session', domain: :all
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
'zh-CN':
|
||||||
|
activemodel:
|
||||||
|
attributes:
|
||||||
|
gitea/user/change_password_form:
|
||||||
|
user: ''
|
||||||
|
email: 邮箱
|
||||||
|
login: 用户名
|
||||||
|
old_password: 旧密码
|
||||||
|
password: 新密码
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
gitea/user/change_password_form:
|
||||||
|
attributes:
|
||||||
|
old_password:
|
||||||
|
password_error: 错误
|
||||||
|
user:
|
||||||
|
not_exist: 不存在
|
||||||
|
|
@ -188,6 +188,7 @@ Rails.application.routes.draw do
|
||||||
get :logout
|
get :logout
|
||||||
get :get_verification_code
|
get :get_verification_code
|
||||||
get :valid_email_and_phone
|
get :valid_email_and_phone
|
||||||
|
post :gitea_register
|
||||||
post :remote_register
|
post :remote_register
|
||||||
post :remote_update
|
post :remote_update
|
||||||
post :remote_login
|
post :remote_login
|
||||||
|
|
@ -223,7 +224,8 @@ Rails.application.routes.draw do
|
||||||
post :sync_salt
|
post :sync_salt
|
||||||
get :trustie_projects
|
get :trustie_projects
|
||||||
get :trustie_related_projects
|
get :trustie_related_projects
|
||||||
post :sync_user_info
|
post :change_password
|
||||||
|
post :change_email
|
||||||
|
|
||||||
scope '/ci', module: :ci do
|
scope '/ci', module: :ci do
|
||||||
scope do
|
scope do
|
||||||
|
|
@ -416,7 +418,6 @@ Rails.application.routes.draw do
|
||||||
member do
|
member do
|
||||||
get :files
|
get :files
|
||||||
get :detail
|
get :detail
|
||||||
get :archive
|
|
||||||
get :entries
|
get :entries
|
||||||
match :sub_entries, :via => [:get, :put]
|
match :sub_entries, :via => [:get, :put]
|
||||||
get :commits
|
get :commits
|
||||||
|
|
@ -431,6 +432,8 @@ Rails.application.routes.draw do
|
||||||
get 'commits/:sha', to: 'repositories#commit', as: 'commit'
|
get 'commits/:sha', to: 'repositories#commit', as: 'commit'
|
||||||
get 'readme'
|
get 'readme'
|
||||||
get 'languages'
|
get 'languages'
|
||||||
|
get 'archive/:archive', to: 'repositories#archive', as: "archive", constraints: { archive: /.+/, format: /(zip|gzip)/ }
|
||||||
|
get 'sonarqube'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddPlatformToUsers < ActiveRecord::Migration[5.2]
|
class AddPlatformToUsers < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :users, :platform, :string, default: 0
|
add_column :users, :platform, :string, default: 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddGiteaTokenToUsers < ActiveRecord::Migration[5.2]
|
class AddGiteaTokenToUsers < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :users, :gitea_token, :string
|
add_column :users, :gitea_token, :string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class AddProjectCategoryIdAndProjectLanguageIdToProjects < ActiveRecord::Migration[5.2]
|
class AddProjectCategoryIdAndProjectLanguageIdToProjects < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :projects, :project_category_id, :integer
|
add_column :projects, :project_category_id, :integer
|
||||||
# add_column :projects, :project_language_id, :integer
|
add_column :projects, :project_language_id, :integer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class AddUserRefToRepository < ActiveRecord::Migration[5.2]
|
class AddUserRefToRepository < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :repositories, :user_id, :integer
|
add_column :repositories, :user_id, :integer
|
||||||
# add_index :repositories, :user_id
|
add_index :repositories, :user_id
|
||||||
|
|
||||||
Project.joins(:repository).find_each do |project|
|
Project.joins(:repository).find_each do |project|
|
||||||
project&.repository&.update_column(:user_id, project&.user_id) unless project&.repository.blank?
|
project&.repository&.update_column(:user_id, project&.user_id) unless project&.repository.blank?
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddGiteaUidToUsers < ActiveRecord::Migration[5.2]
|
class AddGiteaUidToUsers < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :users, :gitea_uid, :integer
|
add_column :users, :gitea_uid, :integer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddMirrorUrlToRepositories < ActiveRecord::Migration[5.2]
|
class AddMirrorUrlToRepositories < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :repositories, :mirror_url, :string
|
add_column :repositories, :mirror_url, :string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
class CreateIssueTags < ActiveRecord::Migration[5.2]
|
class CreateIssueTags < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# create_table :issue_tags do |t|
|
create_table :issue_tags do |t|
|
||||||
# t.string :title
|
t.string :title
|
||||||
# t.string :description
|
t.string :description
|
||||||
# t.string :color
|
t.string :color
|
||||||
# t.integer :user_id
|
t.integer :user_id
|
||||||
# t.integer :project_id
|
t.integer :project_id
|
||||||
# t.integer :issues_count,default: 0
|
t.integer :issues_count,default: 0
|
||||||
# t.timestamps
|
t.timestamps
|
||||||
# end
|
end
|
||||||
# add_index :issue_tags, [:user_id, :title,:project_id]
|
add_index :issue_tags, [:user_id, :title,:project_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddPraisesCountToProjects < ActiveRecord::Migration[5.2]
|
class AddPraisesCountToProjects < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :projects, :praises_count, :integer, :default => 0
|
add_column :projects, :praises_count, :integer, :default => 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
class AddIssuesTypeAndToken < ActiveRecord::Migration[5.2]
|
class AddIssuesTypeAndToken < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :issues, :issue_type, :string
|
add_column :issues, :issue_type, :string
|
||||||
# add_column :issues, :token, :string
|
add_column :issues, :token, :string
|
||||||
# add_column :issues, :issue_tag_ids, :string
|
add_column :issues, :issue_tag_ids, :string
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class RenameIssueTagTitle < ActiveRecord::Migration[5.2]
|
class RenameIssueTagTitle < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# rename_column :issue_tags, :title, :name
|
rename_column :issue_tags, :title, :name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
class CreateIssueTagsRelates < ActiveRecord::Migration[5.2]
|
class CreateIssueTagsRelates < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# create_table :issue_tags_relates do |t|
|
create_table :issue_tags_relates do |t|
|
||||||
# t.integer :issue_id
|
t.integer :issue_id
|
||||||
# t.integer :issue_tag_id
|
t.integer :issue_tag_id
|
||||||
# t.timestamps
|
t.timestamps
|
||||||
# end
|
end
|
||||||
# add_index :issue_tags_relates, [:issue_id, :issue_tag_id]
|
add_index :issue_tags_relates, [:issue_id, :issue_tag_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class RenameIssuesIssueTagIds < ActiveRecord::Migration[5.2]
|
class RenameIssuesIssueTagIds < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# rename_column :issues, :issue_tag_ids, :issue_tags_value
|
rename_column :issues, :issue_tag_ids, :issue_tags_value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
class CreateIssueTimes < ActiveRecord::Migration[5.2]
|
class CreateIssueTimes < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# create_table :issue_times do |t|
|
create_table :issue_times do |t|
|
||||||
# t.integer :issue_id
|
t.integer :issue_id
|
||||||
# t.integer :user_id
|
t.integer :user_id
|
||||||
# t.datetime :start_time
|
t.datetime :start_time
|
||||||
# t.datetime :end_time
|
t.datetime :end_time
|
||||||
# t.string :cost_time
|
t.string :cost_time
|
||||||
# t.timestamps
|
t.timestamps
|
||||||
# end
|
end
|
||||||
# add_index :issue_times, [:issue_id, :user_id]
|
add_index :issue_times, [:issue_id, :user_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddIsLockToIssue < ActiveRecord::Migration[5.2]
|
class AddIsLockToIssue < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :issues, :is_lock, :boolean, default: false
|
add_column :issues, :is_lock, :boolean, default: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
class AddWatchersCountToProjects < ActiveRecord::Migration[5.2]
|
class AddWatchersCountToProjects < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :projects, :watchers_count, :integer, :default => 0
|
add_column :projects, :watchers_count, :integer, :default => 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
class CreateVersionReleases < ActiveRecord::Migration[5.2]
|
class CreateVersionReleases < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# create_table :version_releases do |t|
|
create_table :version_releases do |t|
|
||||||
# t.integer :user_id
|
t.integer :user_id
|
||||||
# t.string :name
|
t.string :name
|
||||||
# t.text :body
|
t.text :body
|
||||||
# t.string :tag_name
|
t.string :tag_name
|
||||||
# t.string :target_commitish
|
t.string :target_commitish
|
||||||
# t.boolean :draft, default: false
|
t.boolean :draft, default: false
|
||||||
# t.boolean :prerelease, default: false
|
t.boolean :prerelease, default: false
|
||||||
# t.string :tarball_url
|
t.string :tarball_url
|
||||||
# t.string :zipball_url
|
t.string :zipball_url
|
||||||
# t.string :url
|
t.string :url
|
||||||
# t.string :version_gid
|
t.string :version_gid
|
||||||
# t.timestamps
|
t.timestamps
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class AddProjectIdToVersionRelease < ActiveRecord::Migration[5.2]
|
class AddProjectIdToVersionRelease < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :version_releases, :repository_id, :integer
|
add_column :version_releases, :repository_id, :integer
|
||||||
# add_index :version_releases, [:repository_id]
|
add_index :version_releases, [:repository_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class AddColumnToIssueTags < ActiveRecord::Migration[5.2]
|
class AddColumnToIssueTags < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
# add_column :issue_tags, :gid, :integer
|
add_column :issue_tags, :gid, :integer
|
||||||
# add_column :issue_tags, :gitea_url, :string
|
add_column :issue_tags, :gitea_url, :string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue