forked from Gitlink/forgeplus
Compare commits
123 Commits
master
...
hh_dev_tru
| Author | SHA1 | Date |
|---|---|---|
|
|
8a43cf9b81 | |
|
|
312fca7e2b | |
|
|
185edc0227 | |
|
|
d1939116a3 | |
|
|
5ecfa0bf4a | |
|
|
2a72fc56a4 | |
|
|
35a59d1b3c | |
|
|
fe8785f620 | |
|
|
913bc45a9f | |
|
|
8131d8cd48 | |
|
|
87049b74ef | |
|
|
f19219a467 | |
|
|
4cc46f4cb4 | |
|
|
fdd8c5ec73 | |
|
|
8331d849d5 | |
|
|
0e7f3a8905 | |
|
|
259090b8e3 | |
|
|
7e474cab70 | |
|
|
01341d4389 | |
|
|
3a475a4674 | |
|
|
7b27ed71ca | |
|
|
83b7b8cd9c | |
|
|
c298ff02b8 | |
|
|
6c3c1ce093 | |
|
|
62d1a2378c | |
|
|
e111f40c69 | |
|
|
8d300e11f9 | |
|
|
b7dd12927b | |
|
|
4126ea7b4e | |
|
|
7bb4cf7391 | |
|
|
539b832af6 | |
|
|
0bfed83bc0 | |
|
|
23f7439a8c | |
|
|
ce8527359c | |
|
|
fff21a1bc8 | |
|
|
526920f564 | |
|
|
2d37df1c00 | |
|
|
0af08bc967 | |
|
|
ea82a52b7b | |
|
|
484f8a854a | |
|
|
62bd331876 | |
|
|
91e142ba82 | |
|
|
7bedac263d | |
|
|
a82b13ecdf | |
|
|
855c51a470 | |
|
|
f0b1c9e80b | |
|
|
dc23be9001 | |
|
|
e24269c2a7 | |
|
|
bf390c8366 | |
|
|
632a06e575 | |
|
|
04c7887319 | |
|
|
d75b79670d | |
|
|
2c5fa8492f | |
|
|
6d845eeb3b | |
|
|
83e666a387 | |
|
|
72b89d4b2b | |
|
|
38f6254edc | |
|
|
8a4b0ba966 | |
|
|
84927c2361 | |
|
|
b568ac4e97 | |
|
|
91bbb58d4f | |
|
|
f278b38e6c | |
|
|
4023b8980e | |
|
|
1c1be18151 | |
|
|
e5f591e509 | |
|
|
27ee32054b | |
|
|
3e3fd46cad | |
|
|
7a752b177d | |
|
|
abbabfdefd | |
|
|
edd76b9286 | |
|
|
a3ca94d433 | |
|
|
91a804caf7 | |
|
|
663deae21b | |
|
|
dae5c9690f | |
|
|
e65df07d79 | |
|
|
246b6b52ec | |
|
|
b9789183e3 | |
|
|
7cf2c6021f | |
|
|
e0f9a3d43d | |
|
|
c1ef39b262 | |
|
|
51643dc02c | |
|
|
a078c07b59 | |
|
|
b984790d5c | |
|
|
876591100e | |
|
|
ba9848ebe7 | |
|
|
41c621cf55 | |
|
|
09ac49dda5 | |
|
|
341a810afc | |
|
|
2282c52efb | |
|
|
34edd78ae7 | |
|
|
36fb5a118c | |
|
|
b756be1d6a | |
|
|
348c2244f7 | |
|
|
31738fc227 | |
|
|
a93c98fb7c | |
|
|
39193324e9 | |
|
|
81743ce3bc | |
|
|
e9ae536f04 | |
|
|
186955fe4a | |
|
|
8ce7fd95cb | |
|
|
0867e5130f | |
|
|
db476a1a9b | |
|
|
fa1fd8a4ba | |
|
|
0d7a11f3ab | |
|
|
879e45e106 | |
|
|
b3b0f75e9b | |
|
|
5c8e561bd8 | |
|
|
2b0c987558 | |
|
|
6796805b21 | |
|
|
5752f19b2f | |
|
|
eb52f05417 | |
|
|
786629dbff | |
|
|
7a00541375 | |
|
|
1d832a1723 | |
|
|
80ce40e492 | |
|
|
91f6dae56a | |
|
|
8c5a834b14 | |
|
|
57f420848e | |
|
|
fba58800a7 | |
|
|
c4a43c4392 | |
|
|
1153bd5ab6 | |
|
|
f732b0374c | |
|
|
0d97d7d4f0 |
|
|
@ -329,7 +329,6 @@ class ApplicationController < ActionController::Base
|
|||
User.current = user
|
||||
end
|
||||
end
|
||||
|
||||
# if !User.current.logged? && Rails.env.development?
|
||||
# User.current = User.find 1
|
||||
# end
|
||||
|
|
@ -771,7 +770,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def base_url
|
||||
request.base_url
|
||||
Rails.application.config_for(:configuration)['platform_url'] || request.base_url
|
||||
end
|
||||
|
||||
def convert_image!
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
module RegisterHelper
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def autologin_register(username, email, password, platform= 'forge')
|
||||
def autologin_register(username, email, password, platform= 'forge', need_edit_info = false)
|
||||
result = {message: nil, user: nil}
|
||||
|
||||
user = User.new(admin: false, login: username, mail: email, type: "User")
|
||||
user.password = password
|
||||
user.platform = platform
|
||||
user.activate
|
||||
if need_edit_info
|
||||
user.need_edit_info
|
||||
else
|
||||
user.activate
|
||||
end
|
||||
|
||||
return unless user.valid?
|
||||
|
||||
|
|
@ -27,4 +31,31 @@ module RegisterHelper
|
|||
result
|
||||
end
|
||||
|
||||
def autosync_register_trustie(username, password, email, lastname="")
|
||||
config = Rails.application.config_for(:configuration).symbolize_keys!
|
||||
|
||||
api_host = config[:sync_url]
|
||||
|
||||
return if api_host.blank?
|
||||
|
||||
url = "#{api_host}/api/v1/users/common"
|
||||
sync_json = {
|
||||
"mail": email,
|
||||
"password": password,
|
||||
"login": username,
|
||||
"lastname": lastname
|
||||
}.compact
|
||||
uri = URI.parse(url)
|
||||
|
||||
if api_host
|
||||
http = Net::HTTP.new(uri.hostname, uri.port)
|
||||
|
||||
if api_host.include?("https://")
|
||||
http.use_ssl = true
|
||||
end
|
||||
|
||||
http.send_request('POST', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ class IssuesController < ApplicationController
|
|||
before_action :load_project
|
||||
before_action :set_user
|
||||
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 :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
|
||||
|
|
@ -230,7 +231,7 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
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_user = @issue.user
|
||||
@issue_assign_to = @issue.get_assign_user
|
||||
|
|
@ -303,7 +304,7 @@ class IssuesController < ApplicationController
|
|||
if issue_ids.present?
|
||||
if update_hash.blank?
|
||||
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, "批量更新成功")
|
||||
else
|
||||
normal_status(-1, "批量更新失败")
|
||||
|
|
@ -315,6 +316,7 @@ class IssuesController < ApplicationController
|
|||
|
||||
def copy
|
||||
@new_issue = @issue.dup
|
||||
@new_issue.author_id = current_user.id
|
||||
if @new_issue.save
|
||||
issue_tags = @issue.issue_tags.pluck(:id)
|
||||
if issue_tags.present?
|
||||
|
|
@ -412,6 +414,10 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def operate_issue_permission
|
||||
return render_forbidden("您没有权限进行此操作.") unless current_user.admin? || @project.member?(current_user)
|
||||
end
|
||||
|
||||
def export_issues(issues)
|
||||
@table_columns = %w(ID 类型 标题 描述 状态 指派给 优先级 标签 发布人 创建时间 里程碑 开始时间 截止时间 完成度 分类 金额 属于)
|
||||
@export_issues = []
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ class Oauth::BaseController < ActionController::Base
|
|||
include RenderHelper
|
||||
include LoginHelper
|
||||
include ControllerRescueHandler
|
||||
include LoggerHelper
|
||||
# include LaboratoryHelper
|
||||
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
|
@ -11,6 +12,18 @@ class Oauth::BaseController < ActionController::Base
|
|||
end
|
||||
|
||||
private
|
||||
def tip_exception(status = -1, message)
|
||||
raise Educoder::TipException.new(status, message)
|
||||
end
|
||||
|
||||
def tip_show_exception(status = -2, message)
|
||||
raise Educoder::TipException.new(status, message)
|
||||
end
|
||||
|
||||
def tip_show(exception)
|
||||
uid_logger("Tip show status is #{exception.status}, message is #{exception.message}")
|
||||
render json: exception.tip_json
|
||||
end
|
||||
|
||||
def session_user_id
|
||||
# session[:user_id]
|
||||
|
|
@ -48,4 +61,13 @@ class Oauth::BaseController < ActionController::Base
|
|||
Rails.logger.info("[wechat] set session unionid: #{unionid}")
|
||||
session[:unionid] = unionid
|
||||
end
|
||||
|
||||
def session_edulogin
|
||||
session[:edulogin]
|
||||
end
|
||||
|
||||
def set_session_edulogin(login)
|
||||
Rails.logger.info("[educoder] set sesstion edulogin: #{login}")
|
||||
session[:edulogin] = login
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class Oauth::EducoderController < Oauth::BaseController
|
||||
include RegisterHelper
|
||||
|
||||
def bind
|
||||
begin
|
||||
login = params[:login]
|
||||
|
|
@ -32,4 +34,41 @@ class Oauth::EducoderController < Oauth::BaseController
|
|||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
|
||||
# 需要educoder那边设置回调地址
|
||||
def create
|
||||
begin
|
||||
code = params['code'].to_s.strip
|
||||
tip_exception("code不能为空") if code.blank?
|
||||
|
||||
new_user = false
|
||||
result = EducoderOauth::Service.access_token(code)
|
||||
result = EducoderOauth::Service.user_info(result[:access_token])
|
||||
|
||||
# 存在该用户
|
||||
open_user = OpenUsers::Educoder.find_by(uid: result['login'])
|
||||
if open_user.present? && open_user.user.present?
|
||||
successful_authentication(open_user.user)
|
||||
else
|
||||
if current_user.blank? || !current_user.logged?
|
||||
new_user = true
|
||||
login = User.generate_login('E')
|
||||
reg_result = autologin_register(login,"#{login}@forge.com", "Ec#{login}2021#", 'educoder', true)
|
||||
if reg_result[:message].blank?
|
||||
open_user = OpenUsers::Educoder.create!(user_id: reg_result[:user][:id], uid: result['login'], extra: result)
|
||||
autosync_register_trustie(login, "Ec#{login}2021#", "#{login}@forge.com")
|
||||
successful_authentication(open_user.user)
|
||||
else
|
||||
render_error(reg_result[:message])
|
||||
end
|
||||
else
|
||||
OpenUsers::Educoder.create!(user: current_user, uid: result['login'], extra: result)
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to root_path(new_user: new_user)
|
||||
rescue Exception => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class OauthController < ApplicationController
|
|||
login = params[:login]
|
||||
email = params[:mail]
|
||||
password = params[:password]
|
||||
lastname = params[:lastname]
|
||||
callback_url = params[:callback_url]
|
||||
platform = params[:plathform] || 'educoder'
|
||||
|
||||
|
|
@ -72,8 +73,11 @@ class OauthController < ApplicationController
|
|||
if result[:message].blank?
|
||||
logger.info "[Oauth educoer] ====auto_register success"
|
||||
user = User.find result[:user][:id]
|
||||
successful_authentication(user)
|
||||
user.update_column(:lastname, params[:lastname])
|
||||
autosync_register_trustie(login, password, email, lastname)
|
||||
|
||||
OpenUsers::Educoder.create!(user: user, uid: user.login)
|
||||
successful_authentication(user)
|
||||
|
||||
render json: { callback_url: callback_url }
|
||||
# redirect_to callback_url
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class ProjectsController < ApplicationController
|
|||
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 :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 :project_public?, only: %i[fork_users praise_users watch_users]
|
||||
|
||||
|
|
@ -116,10 +116,11 @@ class ProjectsController < ApplicationController
|
|||
|
||||
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)
|
||||
@project.update_attributes!(new_project_params)
|
||||
@project.forked_projects.update_all(is_public: @project.is_public)
|
||||
gitea_params = {
|
||||
private: private,
|
||||
default_branch: @project.default_branch,
|
||||
|
|
@ -144,6 +145,7 @@ class ProjectsController < ApplicationController
|
|||
ActiveRecord::Base.transaction do
|
||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
||||
@project.destroy!
|
||||
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||
render_ok
|
||||
end
|
||||
else
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class PullRequestsController < ApplicationController
|
|||
ActiveRecord::Base.transaction do
|
||||
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
||||
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
|
||||
else
|
||||
render_error("create pull request error: #{@gitea_pull_request[:status]}")
|
||||
|
|
@ -91,7 +91,7 @@ class PullRequestsController < ApplicationController
|
|||
if @issue.update_attributes(@issue_params)
|
||||
if @pull_request.update_attributes(@local_params.compact)
|
||||
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 params[:issue_tag_ids].present?
|
||||
|
|
@ -139,7 +139,7 @@ class PullRequestsController < ApplicationController
|
|||
@issue_user = @issue.user
|
||||
@issue_assign_to = @issue.get_assign_user
|
||||
@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
|
||||
|
||||
def pr_merge
|
||||
|
|
@ -191,12 +191,12 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
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 :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 :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_statistics, only: %i[top_counts]
|
||||
|
||||
|
|
@ -192,6 +192,19 @@ class RepositoriesController < ApplicationController
|
|||
render json: languages_precentagable
|
||||
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
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
|
|
@ -266,7 +279,7 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
# uploadPushInfo
|
||||
end
|
||||
|
||||
|
||||
def create_new_pr(params)
|
||||
if params[:new_branch].present? && params[:new_branch] != params[:branch]
|
||||
local_params = {
|
||||
|
|
@ -303,7 +316,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))
|
||||
if local_requests.save
|
||||
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")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class SettingsController < ApplicationController
|
|||
get_add_menu
|
||||
get_common_menu
|
||||
get_personal_menu
|
||||
|
||||
get_third_party
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -40,6 +40,14 @@ class SettingsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def get_third_party
|
||||
@third_party = []
|
||||
@third_party << {
|
||||
name: 'educoder',
|
||||
url: EducoderOauth.oauth_url
|
||||
}
|
||||
end
|
||||
|
||||
def get_site_url(key, value)
|
||||
key.to_s === "url" ? append_http(reset_site_url(value)) : reset_site_url(value)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class UsersController < ApplicationController
|
|||
|
||||
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||
if interactor.success?
|
||||
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_EDIT_INFO)
|
||||
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_ACTIVE)
|
||||
render_ok
|
||||
else
|
||||
render_error(interactor.error)
|
||||
|
|
|
|||
|
|
@ -25,17 +25,13 @@ class VersionsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
version_issues = @version.issues.issue_includes
|
||||
version_issues = @version.issues.issue_issue.issue_includes
|
||||
|
||||
status_type = params[:status_type] || "1"
|
||||
# @close_issues_size = version_issues.where(status_id: 5).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(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"
|
||||
|
|
@ -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.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
|
||||
@limit = params[:limit] || 15
|
||||
@version_issues_size = version_issues.size
|
||||
# @version_issues_size = version_issues.size
|
||||
@version_issues = version_issues.page(@page).per(@limit)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ module ProjectsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def render_zip_url(project, archive_name)
|
||||
[gitea_domain, project.owner.login, project.identifier, "archive", "#{archive_name}.zip"].join('/')
|
||||
def render_zip_url(owner, repository, archive)
|
||||
[base_url, archive_repositories_path(owner&.login, repository, "#{archive}.zip")].join
|
||||
end
|
||||
|
||||
def render_tar_url(project, archive_name)
|
||||
[gitea_domain, project.owner.login, project.identifier, "archive", "#{archive_name}.tar.gz"].join('/')
|
||||
def render_tar_url(owner, repository, archive)
|
||||
[base_url, archive_repositories_path(owner&.login, repository, "#{archive}.tar.gz")].join
|
||||
end
|
||||
|
||||
def render_http_url(project)
|
||||
|
|
|
|||
|
|
@ -24,8 +24,14 @@ module Gitea
|
|||
|
||||
def run
|
||||
Contents::CreateForm.new(valid_params).validate!
|
||||
response = Gitea::Repository::Entries::CreateService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call
|
||||
render_result(response)
|
||||
result = Gitea::Repository::Entries::CreateService.call(token,
|
||||
owner, @params[:identifier], @params[:filepath], file_params)
|
||||
|
||||
if result[:status] == :success
|
||||
@result = result[:body]
|
||||
else
|
||||
fail!(result[:message])
|
||||
end
|
||||
rescue Exception => exception
|
||||
Rails.logger.info "Exception ===========> #{exception.message}"
|
||||
fail!(exception.message)
|
||||
|
|
@ -56,7 +62,7 @@ module Gitea
|
|||
file_params = {}
|
||||
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(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(committer: @params[:committer])
|
||||
file_params
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ class ResetUserCacheJob < ApplicationJob
|
|||
queue_as :cache
|
||||
|
||||
def perform(user)
|
||||
return if user.nil?
|
||||
Cache::UserFollowCountService.new(user).reset
|
||||
Cache::UserIssueCountService.new(user).reset
|
||||
Cache::UserProjectCountService.new(user).reset
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
module EducoderOauth
|
||||
class << self
|
||||
attr_accessor :client_id, :client_secret, :base_url, :redirect_uri
|
||||
|
||||
def logger
|
||||
@_logger ||= STDOUT
|
||||
end
|
||||
|
||||
def logger=(l)
|
||||
@_logger = l
|
||||
end
|
||||
|
||||
def oauth_url
|
||||
"#{base_url}/oauth2?call_url=/oauth/authorize?client_id=#{client_id}&redirect_uri=#{URI.encode_www_form_component(redirect_uri)}&response_type=code"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
require 'oauth2'
|
||||
|
||||
module EducoderOauth::Service
|
||||
module_function
|
||||
|
||||
def request(method, url, params)
|
||||
begin
|
||||
Rails.logger.info("[EducoderOauth] [#{method.to_s.upcase}] #{url} || #{params}")
|
||||
|
||||
client = Faraday.new(url: EducoderOauth.base_url)
|
||||
response = client.public_send(method, url, params)
|
||||
result = JSON.parse(response.body)
|
||||
|
||||
Rails.logger.info("[EducoderOauth] [#{response.status}] #{result}")
|
||||
|
||||
result
|
||||
rescue Exception => e
|
||||
raise Educoder::TipException.new(e.message)
|
||||
end
|
||||
end
|
||||
|
||||
def access_token(code)
|
||||
begin
|
||||
Rails.logger.info("[EducoderOauth] [code] #{code} ")
|
||||
Rails.logger.info("[EducoderOauth] [redirect_uri] #{EducoderOauth.redirect_uri} ")
|
||||
client = OAuth2::Client.new(EducoderOauth.client_id, EducoderOauth.client_secret, site: EducoderOauth.base_url)
|
||||
result = client.auth_code.get_token(code, redirect_uri: EducoderOauth.redirect_uri).to_hash
|
||||
return result
|
||||
rescue Exception => e
|
||||
raise Educoder::TipException.new(e.message)
|
||||
end
|
||||
end
|
||||
|
||||
def user_info(access_token)
|
||||
request(:get, '/api/users/info.json', {access_token: access_token})
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +1,26 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: applied_messages
|
||||
# Table name: forge_applied_messages
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer
|
||||
# applied_id :integer
|
||||
# applied_type :string(255)
|
||||
# applied_id :integer
|
||||
# viewed :integer default("0")
|
||||
# status :integer default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# name :string(255)
|
||||
# applied_user_id :integer
|
||||
# role :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
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: applied_projects
|
||||
# Table name: forge_applied_projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# project_id :integer not null
|
||||
# user_id :integer not null
|
||||
# project_id :integer
|
||||
# user_id :integer
|
||||
# role :integer default("0")
|
||||
# status :integer default("0")
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -1,41 +1,42 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: attachments
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# container_id :integer
|
||||
# container_type :string(30)
|
||||
# filename :string(255) default(""), not null
|
||||
# disk_filename :string(255) default(""), not null
|
||||
# filesize :integer default("0"), not null
|
||||
# content_type :string(255) default("")
|
||||
# digest :string(60) default(""), not null
|
||||
# downloads :integer default("0"), not null
|
||||
# author_id :integer default("0"), not null
|
||||
# created_on :datetime
|
||||
# description :text(65535)
|
||||
# disk_directory :string(255)
|
||||
# attachtype :integer default("1")
|
||||
# is_public :integer default("1")
|
||||
# copy_from :integer
|
||||
# quotes :integer default("0")
|
||||
# is_publish :integer default("1")
|
||||
# publish_time :datetime
|
||||
# resource_bank_id :integer
|
||||
# unified_setting :boolean default("1")
|
||||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# 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_created_on (created_on)
|
||||
# index_attachments_on_is_public (is_public)
|
||||
# index_attachments_on_quotes (quotes)
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: attachments
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# container_id :integer
|
||||
# container_type :string(30)
|
||||
# filename :string(255) default(""), not null
|
||||
# disk_filename :string(255) default(""), not null
|
||||
# filesize :integer default("0"), not null
|
||||
# content_type :string(255) default("")
|
||||
# digest :string(60) default(""), not null
|
||||
# downloads :integer default("0"), not null
|
||||
# author_id :integer default("0"), not null
|
||||
# created_on :datetime
|
||||
# description :text(65535)
|
||||
# disk_directory :string(255)
|
||||
# attachtype :integer default("1")
|
||||
# is_public :integer default("1")
|
||||
# copy_from :string(255)
|
||||
# quotes :integer default("0")
|
||||
# is_publish :integer default("1")
|
||||
# publish_time :datetime
|
||||
# resource_bank_id :integer
|
||||
# unified_setting :boolean default("1")
|
||||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
# link :string(255)
|
||||
# clone_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# index_attachments_on_clone_id (clone_id)
|
||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||
# index_attachments_on_created_on (created_on)
|
||||
#
|
||||
|
||||
|
||||
|
||||
class Attachment < ApplicationRecord
|
||||
|
|
|
|||
|
|
@ -39,17 +39,15 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# gitea_uid :integer
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# sponsor_certification :integer default("0")
|
||||
# sponsor_num :integer default("0")
|
||||
# sponsored_num :integer default("0")
|
||||
# award_time :datetime
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
@ -57,8 +55,9 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ module ProjectOperable
|
|||
if owner.is_a?(User)
|
||||
managers.exists?(user_id: user.id)
|
||||
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
|
||||
false
|
||||
end
|
||||
|
|
@ -94,7 +94,7 @@ module ProjectOperable
|
|||
end
|
||||
|
||||
def operator?(user)
|
||||
user.admin? || !reporter?(user)
|
||||
user.admin? || (member?(user.id) && !reporter?(user))
|
||||
end
|
||||
|
||||
def set_developer_role(member, role_name)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
class Gitea::Base < Gitea::Database
|
||||
self.abstract_class = true
|
||||
|
||||
class Gitea::Base < ApplicationRecord
|
||||
db_config = Rails.configuration.database_configuration[Rails.env]["gitea_server"]
|
||||
raise 'gitea database config missing' if db_config.blank?
|
||||
|
||||
establish_connection db_config
|
||||
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_subject :boolean default("0")
|
||||
# sync_shixun :boolean default("0")
|
||||
# is_local :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
# content :text(65535)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# is_secret :boolean default("0")
|
||||
#
|
||||
|
||||
class License < ApplicationRecord
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
# course_group_id :integer default("0")
|
||||
# is_collect :integer default("1")
|
||||
# graduation_group_id :integer default("0")
|
||||
# is_apply_signature :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -39,17 +39,15 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# gitea_uid :integer
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# sponsor_certification :integer default("0")
|
||||
# sponsor_num :integer default("0")
|
||||
# sponsored_num :integer default("0")
|
||||
# award_time :datetime
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
@ -57,8 +55,9 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
|
|
|||
|
|
@ -1,78 +1,80 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
# parent_id :integer
|
||||
# created_on :datetime
|
||||
# updated_on :datetime
|
||||
# identifier :string(255)
|
||||
# status :integer default("1"), not null
|
||||
# lft :integer
|
||||
# rgt :integer
|
||||
# inherit_members :boolean default("0"), not null
|
||||
# project_type :integer default("0")
|
||||
# hidden_repo :boolean default("0"), not null
|
||||
# attachmenttype :integer default("1")
|
||||
# user_id :integer
|
||||
# dts_test :integer default("0")
|
||||
# enterprise_name :string(255)
|
||||
# organization_id :integer
|
||||
# project_new_type :integer
|
||||
# gpid :integer
|
||||
# forked_from_project_id :integer
|
||||
# forked_count :integer default("0")
|
||||
# publish_resource :integer default("0")
|
||||
# visits :integer default("0")
|
||||
# hot :integer default("0")
|
||||
# invite_code :string(255)
|
||||
# qrcode :string(255)
|
||||
# qrcode_expiretime :integer default("0")
|
||||
# script :text(65535)
|
||||
# training_status :integer default("0")
|
||||
# rep_identifier :string(255)
|
||||
# project_category_id :integer
|
||||
# project_language_id :integer
|
||||
# license_id :integer
|
||||
# ignore_id :integer
|
||||
# praises_count :integer default("0")
|
||||
# watchers_count :integer default("0")
|
||||
# issues_count :integer default("0")
|
||||
# pull_requests_count :integer default("0")
|
||||
# language :string(255)
|
||||
# versions_count :integer default("0")
|
||||
# issue_tags_count :integer default("0")
|
||||
# closed_issues_count :integer default("0")
|
||||
# open_devops :boolean default("0")
|
||||
# gitea_webhook_id :integer
|
||||
# open_devops_count :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# platform :integer default("0")
|
||||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
# order_index :integer default("0")
|
||||
# lesson_url :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||
# index_projects_on_identifier (identifier)
|
||||
# index_projects_on_invite_code (invite_code)
|
||||
# index_projects_on_is_public (is_public)
|
||||
# index_projects_on_lft (lft)
|
||||
# index_projects_on_name (name)
|
||||
# index_projects_on_platform (platform)
|
||||
# index_projects_on_project_type (project_type)
|
||||
# index_projects_on_recommend (recommend)
|
||||
# index_projects_on_rgt (rgt)
|
||||
# index_projects_on_status (status)
|
||||
# index_projects_on_updated_on (updated_on)
|
||||
#
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
# parent_id :integer
|
||||
# created_on :datetime
|
||||
# updated_on :datetime
|
||||
# identifier :string(255)
|
||||
# status :integer default("1"), not null
|
||||
# lft :integer
|
||||
# rgt :integer
|
||||
# inherit_members :boolean default("0"), not null
|
||||
# project_type :integer default("0")
|
||||
# hidden_repo :boolean default("0"), not null
|
||||
# attachmenttype :integer default("1")
|
||||
# user_id :integer
|
||||
# dts_test :integer default("0")
|
||||
# enterprise_name :string(255)
|
||||
# organization_id :integer
|
||||
# project_new_type :integer
|
||||
# gpid :integer
|
||||
# forked_from_project_id :integer
|
||||
# forked_count :integer default("0")
|
||||
# publish_resource :integer default("0")
|
||||
# visits :integer default("0")
|
||||
# hot :integer default("0")
|
||||
# invite_code :string(255)
|
||||
# qrcode :string(255)
|
||||
# qrcode_expiretime :integer default("0")
|
||||
# script :text(65535)
|
||||
# training_status :integer default("0")
|
||||
# rep_identifier :string(255)
|
||||
# project_category_id :integer
|
||||
# project_language_id :integer
|
||||
# praises_count :integer default("0")
|
||||
# watchers_count :integer default("0")
|
||||
# issues_count :integer default("0")
|
||||
# pull_requests_count :integer default("0")
|
||||
# language :string(255)
|
||||
# versions_count :integer default("0")
|
||||
# issue_tags_count :integer default("0")
|
||||
# closed_issues_count :integer default("0")
|
||||
# open_devops :boolean default("0")
|
||||
# gitea_webhook_id :integer
|
||||
# open_devops_count :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# platform :integer default("0")
|
||||
# license_id :integer
|
||||
# ignore_id :integer
|
||||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
# lesson_url :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||
# index_projects_on_identifier (identifier)
|
||||
# index_projects_on_invite_code (invite_code)
|
||||
# index_projects_on_is_public (is_public)
|
||||
# index_projects_on_lft (lft)
|
||||
# index_projects_on_license_id (license_id)
|
||||
# index_projects_on_name (name)
|
||||
# index_projects_on_platform (platform)
|
||||
# index_projects_on_project_category_id (project_category_id)
|
||||
# index_projects_on_project_language_id (project_language_id)
|
||||
# index_projects_on_project_type (project_type)
|
||||
# index_projects_on_recommend (recommend)
|
||||
# index_projects_on_rgt (rgt)
|
||||
# index_projects_on_status (status)
|
||||
# index_projects_on_updated_on (updated_on)
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -98,10 +100,12 @@ class Project < ApplicationRecord
|
|||
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_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 :watchers, as: :watchable, 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_projects, class_name: 'Project', foreign_key: :forked_from_project_id
|
||||
has_one :project_educoder, dependent: :destroy
|
||||
|
||||
has_one :project_score, dependent: :destroy
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@
|
|||
# projects_count :integer default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ancestry :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_project_categories_on_ancestry (ancestry)
|
||||
#
|
||||
|
||||
class ProjectCategory < ApplicationRecord
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class PullRequest < ApplicationRecord
|
|||
has_many :pull_request_tags, foreign_key: :pull_request_id
|
||||
has_many :project_trends, as: :trend, 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 :opening, -> {where(status: 0)}
|
||||
|
|
@ -53,8 +54,10 @@ class PullRequest < ApplicationRecord
|
|||
Project.find_by(id: self.fork_project_id)
|
||||
end
|
||||
|
||||
def bind_gitea_pull_request!(gitea_pull_number)
|
||||
update_column(:gpid, gitea_pull_number)
|
||||
def bind_gitea_pull_request!(gitea_pull_number, gitea_pull_id)
|
||||
update_columns(
|
||||
gitea_number: gitea_pull_number,
|
||||
gitea_id: gitea_pull_id)
|
||||
end
|
||||
|
||||
def merge!
|
||||
|
|
@ -67,19 +70,26 @@ class PullRequest < ApplicationRecord
|
|||
|
||||
# TODO: sync educoder platform repo's for update some statistics 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
|
||||
next if pr.gpid.blank?
|
||||
next if pr.gitea_number.blank?
|
||||
project = pr.project
|
||||
|
||||
next if project.blank?
|
||||
user = project.owner
|
||||
next if pr.gpid === 6 || pr.gpid === 7
|
||||
files_result = Gitea::PullRequest::FilesService.call(user.login, project.identifier, pr.gpid)
|
||||
next if pr.gitea_number === 6 || pr.gitea_number === 7
|
||||
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?
|
||||
|
||||
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?
|
||||
end
|
||||
end
|
||||
|
||||
def conflict_files
|
||||
file_names = self&.gitea_pull&.conflicted_files
|
||||
return [] if file_names.blank?
|
||||
|
||||
JSON.parse file_names
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_repositories_on_identifier (identifier)
|
||||
# index_repositories_on_project_id (project_id)
|
||||
# index_repositories_on_user_id (user_id)
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: tokens
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer default("0"), not null
|
||||
# action :string(30) default(""), not null
|
||||
# value :string(40) default(""), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_tokens_on_user_id (user_id)
|
||||
# tokens_value (value) UNIQUE
|
||||
#
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: tokens
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer default("0"), not null
|
||||
# action :string(30) default(""), not null
|
||||
# value :string(40) default(""), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_tokens_on_user_id (user_id)
|
||||
# tokens_value (value) UNIQUE
|
||||
#
|
||||
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
|
@ -76,7 +76,7 @@ class Token < ActiveRecord::Base
|
|||
# Returns the active user who owns the key for the given action
|
||||
def self.find_active_user(action, key, validity_days=nil)
|
||||
user = find_user(action, key, validity_days)
|
||||
if user && user.active?
|
||||
if user && (user.active? || user.need_edit_info?)
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,17 +39,15 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# gitea_uid :integer
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# sponsor_certification :integer default("0")
|
||||
# sponsor_num :integer default("0")
|
||||
# sponsored_num :integer default("0")
|
||||
# award_time :datetime
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
@ -57,8 +55,9 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
|
@ -84,6 +83,7 @@ class User < Owner
|
|||
STATUS_ACTIVE = 1
|
||||
STATUS_REGISTERED = 2
|
||||
STATUS_LOCKED = 3
|
||||
STATUS_EDIT_INFO = 4
|
||||
|
||||
# tpi tpm权限控制
|
||||
EDU_ADMIN = 1 # 超级管理员
|
||||
|
|
@ -172,7 +172,7 @@ class User < Owner
|
|||
has_many :pull_requests, dependent: :destroy
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(status: STATUS_ACTIVE) }
|
||||
scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) }
|
||||
scope :like, lambda { |keywords|
|
||||
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
|
||||
where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
|
||||
|
|
@ -186,7 +186,7 @@ class User < Owner
|
|||
:show_email, :show_location, :show_department,
|
||||
: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
|
||||
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
|
||||
end
|
||||
|
|
@ -410,6 +410,10 @@ class User < Owner
|
|||
status == STATUS_LOCKED
|
||||
end
|
||||
|
||||
def need_edit_info?
|
||||
status == STATUS_EDIT_INFO
|
||||
end
|
||||
|
||||
def activate
|
||||
self.status = STATUS_ACTIVE
|
||||
end
|
||||
|
|
@ -422,6 +426,10 @@ class User < Owner
|
|||
self.status = STATUS_LOCKED
|
||||
end
|
||||
|
||||
def need_edit_info
|
||||
self.status = STATUS_EDIT_INFO
|
||||
end
|
||||
|
||||
def activate!
|
||||
update_attribute(:status, STATUS_ACTIVE)
|
||||
end
|
||||
|
|
@ -434,6 +442,10 @@ class User < Owner
|
|||
update_attribute(:status, STATUS_LOCKED)
|
||||
end
|
||||
|
||||
def need_edit_info!
|
||||
update_attribute(:status, STATUS_EDIT_INFO)
|
||||
end
|
||||
|
||||
# 课程用户身份
|
||||
def course_identity(course)
|
||||
if !logged?
|
||||
|
|
@ -779,6 +791,10 @@ class User < Owner
|
|||
|
||||
self.laboratory = Laboratory.current if laboratory_id.blank?
|
||||
end
|
||||
|
||||
def set_lastname
|
||||
self.lastname = self.nickname if changes[:nickname].present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
#
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -10,10 +10,13 @@
|
|||
# updated_at :datetime not null
|
||||
# register_status :integer default("0")
|
||||
# action_status :integer default("0")
|
||||
# is_delete :boolean default("0")
|
||||
# user_id :integer
|
||||
#
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
# school_id :integer
|
||||
# description :string(255) default("")
|
||||
# department_id :integer
|
||||
# honor :text(65535)
|
||||
# edu_background :integer
|
||||
# edu_entry_year :integer
|
||||
# province :string(255)
|
||||
# city :string(255)
|
||||
# custom_department :string(255)
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ class Cache::PlatformProjectLanguagesCountService < ApplicationService
|
|||
|
||||
def reset_platform_project_language_count_by_key
|
||||
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
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -214,6 +214,14 @@ class Gitea::ClientService < ApplicationService
|
|||
[body, message]
|
||||
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)
|
||||
puts "[gitea] status: #{status}"
|
||||
puts "[gitea] body: #{body&.force_encoding('UTF-8')}"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::CloseService < Gitea::PullRequest::UpdateService
|
|||
# number: number of pull request
|
||||
# token: token of gitea user
|
||||
# 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)
|
||||
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
|
||||
|
||||
#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)
|
||||
@owner = owner
|
||||
@repo = repo
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class Gitea::PullRequest::OpenService < Gitea::PullRequest::UpdateService
|
|||
# number: number of pull request
|
||||
# token: token of gitea user
|
||||
# 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)
|
||||
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
|
||||
|
|
@ -30,8 +30,7 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
|||
|
||||
def call
|
||||
response = post(url, params)
|
||||
|
||||
render_201_response(response)
|
||||
response_payload(response)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -43,4 +42,21 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
|||
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".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 201 then success(json_parse!(body))
|
||||
when 403 then error("你没有权限操作!")
|
||||
when 404 then error("你操作的链接不存在!")
|
||||
when 422 then error("#{filepath}文件已存在,不能重复创建!")
|
||||
else error("系统错误!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class Projects::CreateService < ApplicationService
|
|||
|
||||
def call
|
||||
Rails.logger.info("#############__________project_params______###########{project_params}")
|
||||
raise Error, "user_id不正确." unless authroize_user_id_success
|
||||
|
||||
@project = Project.new(project_params)
|
||||
ActiveRecord::Base.transaction do
|
||||
|
|
@ -27,6 +28,10 @@ class Projects::CreateService < ApplicationService
|
|||
|
||||
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
|
||||
{
|
||||
name: params[:name],
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class Projects::MigrateService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
raise Error, "user_id不正确." unless authroize_user_id_success
|
||||
|
||||
@project = Project.new(project_params)
|
||||
if @project.save!
|
||||
ProjectUnit.init_types(@project.id, project.project_type)
|
||||
|
|
@ -24,6 +26,9 @@ class Projects::MigrateService < ApplicationService
|
|||
end
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class PullRequests::CloseService < ApplicationService
|
|||
|
||||
def close_gitea_pull
|
||||
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
|
||||
|
||||
def update_pull_status!
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class PullRequests::MergeService < ApplicationService
|
|||
|
||||
def gitea_pull_merge!
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class PullRequests::OpenService < ApplicationService
|
|||
|
||||
def open_gitea_pull
|
||||
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
|
||||
|
||||
def update_pull_status!
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
<div class="indexPanel">
|
||||
<p class="indexTitle">完善信息,进入比赛</p>
|
||||
<p class="indexTitle">平台已检测到您的如下信息,完善即可进入比赛</p>
|
||||
<div class="indexInfos">
|
||||
|
||||
<%= form_tag('', method: :post, id: 'oauth_form', class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<%= hidden_field_tag 'callback_url', params[:callback_url] %>
|
||||
<div class="indexInfo">
|
||||
<span>用户名:</span>
|
||||
<%= text_field_tag :login, params[:login], placeholder: '请输入用户名', readonly: true, id: 'login' %>
|
||||
<span>登录名:</span>
|
||||
<%= text_field_tag :login, params[:login], placeholder: '请输入登录名', readonly: true, id: 'login' %>
|
||||
<p class="checkInfo loginCheck"><span></span></p>
|
||||
</div>
|
||||
<div class="indexInfo">
|
||||
<span>用户名称:</span>
|
||||
<%= text_field_tag :lastname, params[:lastname], placeholder: '登录平台后显示的用户名称', maxlength: 40, id: 'lastname' %>
|
||||
<p class="checkInfo lastnameCheck"><span></span></p>
|
||||
</div>
|
||||
<div class="indexInfo">
|
||||
<span>邮箱:</span>
|
||||
<%= text_field_tag :mail, params[:mail], placeholder: '请输入绑定邮箱', maxlength: 40, id: 'email' %>
|
||||
|
|
@ -16,7 +21,7 @@
|
|||
</div>
|
||||
<div class="indexInfo">
|
||||
<span>密码:</span>
|
||||
<%= password_field_tag :password, '', placeholder: '请输入账号密码', id: 'password' %>
|
||||
<%= password_field_tag :password, '', placeholder: '输入EduCoder账号密码或新的密码',maxlength: 15, id: 'password' %>
|
||||
<p class="checkInfo passwordCheck"><span></span></p>
|
||||
</div>
|
||||
<div class="indexBtn">
|
||||
|
|
@ -29,6 +34,7 @@
|
|||
function submitdata(){
|
||||
var login = $("#login").val();
|
||||
var email = $("#email").val();
|
||||
var lastname = $("#lastname").val();
|
||||
var password = $("#password").val();
|
||||
|
||||
if(!login){
|
||||
|
|
@ -37,6 +43,12 @@
|
|||
}else{
|
||||
$(".loginCheck span").html("");
|
||||
}
|
||||
if(!lastname){
|
||||
$(".lastnameCheck span").html("请输入用户名称");
|
||||
return;
|
||||
}else{
|
||||
$(".lastnameCheck span").html("");
|
||||
}
|
||||
if(!email){
|
||||
$(".emailCheck span").html("请输入绑定的邮箱");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ json.array! @branches do |branch|
|
|||
json.user_can_merge branch['user_can_merge']
|
||||
json.protected branch['protected']
|
||||
json.http_url render_http_url(@project)
|
||||
json.zip_url render_zip_url(@project, branch['name'])
|
||||
json.tar_url render_tar_url(@project, branch['name'])
|
||||
json.zip_url render_zip_url(@owner, @repository, branch['name'])
|
||||
json.tar_url render_tar_url(@owner, @repository, branch['name'])
|
||||
json.last_commit do
|
||||
json.sha branch['commit']['id']
|
||||
json.message branch['commit']['message']
|
||||
|
|
|
|||
|
|
@ -32,3 +32,5 @@ json.issue do
|
|||
json.version @issue.version.try(:name)
|
||||
json.issue_tags @issue.get_issue_tags
|
||||
end
|
||||
|
||||
json.conflict_files @pull_request.conflict_files
|
||||
|
|
|
|||
|
|
@ -42,8 +42,9 @@ if @project.forge?
|
|||
#json.tags_count @tags_count
|
||||
#json.branches_count @branches_count
|
||||
json.commits_count @commits_count
|
||||
json.zip_url render_zip_url(@project, @ref)
|
||||
json.tar_url render_tar_url(@project, @ref)
|
||||
# json.zip_url archive_repositories_path(@owner&.login, @repository, @ref)
|
||||
json.zip_url render_zip_url(@owner, @repository, @ref)
|
||||
json.tar_url render_tar_url(@owner, @repository, @ref)
|
||||
json.entries do
|
||||
json.array! @entries do |entry|
|
||||
json.name entry['name']
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ json.array! @tags do |tag|
|
|||
if tag.present?
|
||||
json.name tag['name']
|
||||
json.id tag['id']
|
||||
json.zipball_url tag['zipball_url']
|
||||
json.tarball_url tag['tarball_url']
|
||||
json.zipball_url render_zip_url(@owner, @repository, tag['name'])
|
||||
json.tarball_url render_tar_url(@owner, @repository, tag['name'])
|
||||
json.commit do
|
||||
json.sha tag['commit']['sha']
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,4 +56,5 @@ json.setting do
|
|||
end
|
||||
|
||||
json.common @common
|
||||
json.third_party @third_party
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ json.is_teacher @user.user_extension&.teacher?
|
|||
json.user_identity @user.identity
|
||||
json.tidding_count 0
|
||||
json.user_phone_binded @user.phone.present?
|
||||
json.need_edit_info @user.need_edit_info?
|
||||
# json.phone @user.phone
|
||||
# json.email @user.mail
|
||||
json.email @user.mail
|
||||
json.profile_completed @user.profile_completed?
|
||||
json.professional_certification @user.professional_certification
|
||||
json.devops_step @user.devops_step
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ json.releases do
|
|||
json.name re["name"]
|
||||
json.body re["body"]
|
||||
json.url re["url"]
|
||||
json.tarball_url re["tarball_url"]
|
||||
json.zipball_url re["zipball_url"]
|
||||
json.tarball_url render_tar_url(@owner, @repository, re["tag_name"])
|
||||
json.zipball_url render_zip_url(@owner, @repository, re["tag_name"])
|
||||
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
||||
json.created_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.body re["body"]
|
||||
json.url re["url"]
|
||||
json.tarball_url re["tarball_url"]
|
||||
json.zipball_url re["zipball_url"]
|
||||
json.tarball_url render_tar_url(@owner, @repository, re["tag_name"])
|
||||
json.zipball_url render_zip_url(@owner, @repository, re["tag_name"])
|
||||
json.draft re["draft"] ? "草稿" : (re["prerelease"] ? "预发行" : "稳定")
|
||||
json.created_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.extract! version, :id, :name, :description, :effective_date,:status,:percent
|
||||
json.open_issues_count (version.issues_count - version.closed_issues_count)
|
||||
json.close_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.issues.issue_issue.closed.size
|
||||
json.created_at format_time(version.created_on)
|
||||
json.updated_at format_time(version.updated_on)
|
||||
json.user_name version.version_user.try(:show_real_name)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
json.partial! "commons/success"
|
||||
json.issues_count @version.issues_count
|
||||
json.open_issues_count @version.issues_count - @version.closed_issues_count
|
||||
json.close_issues_count @version.closed_issues_count
|
||||
json.issues_count @version_issues_size
|
||||
json.open_issues_count @version_issues_size - @version_close_issues_size
|
||||
json.close_issues_count @version_close_issues_size
|
||||
json.limit @limit
|
||||
json.user_name @version.version_user.try(:show_real_name)
|
||||
json.user_login @version.version_user.try(:login)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
default: &default
|
||||
# 用户登入的时候设置/登出的时候清空
|
||||
autologin_cookie_name: 'autologin_trustie'
|
||||
platform_url: 'http://localhost:3000'
|
||||
|
||||
|
||||
#附件上传路径
|
||||
|
|
@ -43,6 +44,11 @@ default: &default
|
|||
cate_id: '-1'
|
||||
callback_url: 'callback_url'
|
||||
signature_key: 'test12345678'
|
||||
educoder:
|
||||
client_id: 'e9ce4d5ba1698d6f7d01d8ee2959776c7a6d743ebe94da2341e288fd2fbf60aa'
|
||||
client_secret: '6ff84dd75eddd859c5bd0e7a791b58bc5ad1ba4fbb30bc9db37cb0baf9f33012'
|
||||
base_url: 'https://test-data.educoder.net'
|
||||
redirect_uri: 'https://testforgeplus.trustie.net/api/auth/educoder/callback'
|
||||
|
||||
gitea:
|
||||
access_key_id: ''
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ default: &default
|
|||
username: root
|
||||
password: 123456
|
||||
# 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:
|
||||
<<: *default
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
oauth_config = {}
|
||||
begin
|
||||
config = Rails.application.config_for(:configuration)
|
||||
oauth_config = config.dig('oauth', 'educoder')
|
||||
raise 'oauth educoder config missing' if oauth_config.blank?
|
||||
rescue => ex
|
||||
raise ex if Rails.env.production?
|
||||
|
||||
puts %Q{\033[33m [warning] wechat oauth config or configuration.yml missing,
|
||||
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
|
||||
end
|
||||
|
||||
EducoderOauth.client_id = oauth_config['client_id']
|
||||
EducoderOauth.client_secret = oauth_config['client_secret']
|
||||
EducoderOauth.base_url = oauth_config['base_url']
|
||||
EducoderOauth.redirect_uri = oauth_config['redirect_uri']
|
||||
|
|
@ -4,5 +4,5 @@
|
|||
# Rails.application.config.session_store :active_record_store
|
||||
|
||||
# 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
|
||||
|
||||
|
|
|
|||
|
|
@ -346,6 +346,7 @@ Rails.application.routes.draw do
|
|||
|
||||
get '/auth/qq/callback', to: 'oauth/qq#create'
|
||||
get '/auth/wechat/callback', to: 'oauth/wechat#create'
|
||||
get '/auth/educoder/callback', to: 'oauth/educoder#create'
|
||||
resource :bind_user, only: [:create]
|
||||
|
||||
resources :hot_keywords, only: [:index]
|
||||
|
|
@ -416,7 +417,6 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
get :files
|
||||
get :detail
|
||||
get :archive
|
||||
get :entries
|
||||
match :sub_entries, :via => [:get, :put]
|
||||
get :commits
|
||||
|
|
@ -431,6 +431,7 @@ Rails.application.routes.draw do
|
|||
get 'commits/:sha', to: 'repositories#commit', as: 'commit'
|
||||
get 'readme'
|
||||
get 'languages'
|
||||
get 'archive/:archive', to: 'repositories#archive', as: "archive", constraints: { archive: /.+/, format: /(zip|gzip)/ }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
class AddProjectLanguageIndexToProjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :projects, :project_category_id
|
||||
add_index :projects, :project_language_id
|
||||
add_index :projects, :license_id
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
class ChangeColumnsNameFromPullRequests < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
rename_column :pull_requests, :pull_request_id, :gitea_id
|
||||
rename_column :pull_requests, :gpid, :gitea_number
|
||||
|
||||
|
||||
PullRequest.find_each do |pr|
|
||||
next if pr.gitea_number.blank?
|
||||
|
||||
project = pr.project
|
||||
next if project.blank?
|
||||
|
||||
owner = project&.owner
|
||||
gitea_pull = Gitea::PullRequest::GetService.call(owner.login, project.identifier, pr.gitea_number, owner&.gitea_token)
|
||||
|
||||
next if gitea_pull.blank?
|
||||
|
||||
pr.update_column(:gitea_id, gitea_pull["id"])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
namespace :sync_projects_by_forked_project do
|
||||
desc "sync projects is_public by forked project"
|
||||
task is_public: :environment do
|
||||
count = 0
|
||||
Project.where.not(forked_from_project_id: nil).group(:forked_from_project_id).count.each do |k, _|
|
||||
project = Project.find_by_id(k)
|
||||
need_update_forked_projects = Project.where(forked_from_project_id: k)
|
||||
need_update_forked_projects.update_all(is_public: project&.is_public)
|
||||
need_update_forked_repositories = Repository.where(project_id: need_update_forked_projects.ids)
|
||||
need_update_forked_repositories.update_all(hidden: !project&.is_public)
|
||||
count +=need_update_forked_projects.size
|
||||
end
|
||||
puts "共同步了#{count}个项目"
|
||||
end
|
||||
|
||||
task destroy: :environment do
|
||||
count = 0
|
||||
Project.where.not(forked_from_project_id: nil).find_each do |project|
|
||||
if project.forked_from_project.nil?
|
||||
project.update(forked_from_project_id: nil)
|
||||
count +=1
|
||||
end
|
||||
end
|
||||
puts "共同步了#{count}个项目"
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue