forked from Gitlink/forgeplus
Merge branch 'standalone_develop' into dev_osredm_server
This commit is contained in:
commit
691620c874
|
@ -5,9 +5,11 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController
|
|||
return render_error('请输入正确的用户ID.') if params[:user_id].blank?
|
||||
@all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']})
|
||||
@all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
|
||||
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct
|
||||
@weekly_begin_date = params[:weekly_begin_date].to_time || Date.today.beginning_of_week rescue Date.today.beginning_of_week
|
||||
@weekly_end_date = params[:weekly_end_date].to_time || Date.today.end_of_week rescue Date.today.end_of_week
|
||||
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", @weekly_begin_date.to_s, @weekly_end_date.to_s).distinct
|
||||
@this_week_all_issues = @this_week_all_issues.order('created_on desc').pm_includes
|
||||
@next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (Date.today.beginning_of_week+1.week).to_s, (Date.today.end_of_week+1.week).to_s).distinct
|
||||
@next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (@weekly_begin_date+1.week).to_s, (@weekly_end_date+1.week).to_s).distinct
|
||||
@next_week_all_issues = @next_week_all_issues.order('created_on desc').pm_includes
|
||||
@this_week_requirement_issues = @this_week_all_issues.where(pm_issue_type: 1)
|
||||
@this_week_task_issues = @this_week_all_issues.where(pm_issue_type: 2)
|
||||
|
@ -27,7 +29,9 @@ class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController
|
|||
@enterprise_identifier = params[:enterprise_identifier] || ''
|
||||
@all_issues = Issue.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
|
||||
@all_issues = @all_issues.where(pm_project_id: params[:pm_project_ids].split(",")) if params[:pm_project_ids].present?
|
||||
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s)
|
||||
@weekly_begin_date = params[:weekly_begin_date] || Date.today.beginning_of_week.to_s
|
||||
@weekly_end_date = params[:weekly_end_date] || Date.today.end_of_week.to_s
|
||||
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", @weekly_begin_date, @weekly_end_date)
|
||||
@this_week_all_issues_group_count = @this_week_all_issues.group(:pm_project_id).count
|
||||
data = {}
|
||||
@this_week_all_issues_group_count.keys.each do |pm_project_id|
|
||||
|
|
|
@ -37,6 +37,11 @@ class Api::V1::BaseController < ApplicationController
|
|||
params.fetch(:page, 1)
|
||||
end
|
||||
|
||||
def load_organization
|
||||
@organization = Organization.find_by(login: params[:owner]) || Organization.find_by(id: params[:owner])
|
||||
return render_not_found("组织不存在") if @organization.nil?
|
||||
end
|
||||
|
||||
# 具有对仓库的管理权限
|
||||
def require_manager_above
|
||||
@project = load_project
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
class Api::V1::Organizations::SyncRepositoriesController < Api::V1::BaseController
|
||||
before_action :load_organization, only: [:create]
|
||||
|
||||
def create
|
||||
return render_error("请输入正确的外部组织login") unless params[:external_login].present?
|
||||
# 拉取外部组织仓库列表
|
||||
url = URI("https://api.github.com/orgs/#{params[:external_login]}/repos?page=#{params[:page]}&per_page=#{params[:limit]}")
|
||||
https = Net::HTTP.new(url.host, url.port)
|
||||
https.use_ssl = true
|
||||
request = Net::HTTP::Get.new(url)
|
||||
request["Authorization"] = "Bearer #{params[:external_token]}"
|
||||
response = https.request(request)
|
||||
if response.code == "200"
|
||||
repos = JSON.parse(response.body)
|
||||
repos.each do |repo|
|
||||
# 检查是否已经存在该仓库
|
||||
@project = @organization.projects.find_by(identifier: repo["name"])
|
||||
if @project.present?
|
||||
if @project.repository.mirror.failed?
|
||||
@project.destroy!
|
||||
mirror_params = {name: repo["name"], user_id: @organization.id, description: repo["description"], repository_name: repo["name"], auth_token: params[:external_token], clone_addr: repo["clone_url"]}
|
||||
@project = ::Projects::MigrateService.call(current_user, mirror_params)
|
||||
end
|
||||
@project.update_column(:created_on, repo['created_at'].to_time)
|
||||
@project.update_column(:updated_on, repo['updated_at'].to_time)
|
||||
next
|
||||
else
|
||||
mirror_params = {name: repo["name"], user_id: @organization.id, description: repo["description"], repository_name: repo["name"], auth_token: params[:external_token], clone_addr: repo["clone_url"]}
|
||||
@project = ::Projects::MigrateService.call(current_user, mirror_params)
|
||||
@project.update_column(:created_on, repo['created_at'].to_time)
|
||||
@project.update_column(:updated_on, repo['updated_at'].to_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def sync_repository_params
|
||||
params.permit(:external_token)
|
||||
end
|
||||
|
||||
end
|
|
@ -37,6 +37,7 @@ class AttachmentsController < ApplicationController
|
|||
Rails.logger.info("request.host===#{request.host},request.referer===#{request.referer}")
|
||||
tip_exception(403, "你没有权限访问") if request.host.present? && !request.referer.to_s.include?(request.host.to_s.gsub("www.",""))
|
||||
normal_status(-1, "参数缺失") if params[:download_url].blank?
|
||||
tip_exception('不可访问') if params[:download_url].to_s.include?("chinese_dictionary.txt")
|
||||
url = base_url.starts_with?("https:") ? params[:download_url].to_s.gsub("http:", "https:") : params[:download_url].to_s
|
||||
if url.starts_with?(base_url) && !url.starts_with?("#{base_url}/repo")
|
||||
domain = GiteaService.gitea_config[:domain]
|
||||
|
|
|
@ -7,7 +7,7 @@ class MainController < ApplicationController
|
|||
#before_action :sso_login, only: [:index]
|
||||
|
||||
def first_stamp
|
||||
render :json => { status: 0, message: Time.now.to_i }
|
||||
render :json => { status: 0, message: Time.now.to_i, online: UserOnline.count }
|
||||
end
|
||||
|
||||
def test_404
|
||||
|
|
|
@ -85,7 +85,7 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
def sub_entries
|
||||
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
|
||||
|
||||
tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt")
|
||||
if @project.educoder?
|
||||
if params[:type] === 'file'
|
||||
@sub_entries = Educoder::Repository::Entries::GetService.call(@project&.project_educoder&.repo_name, file_path_uri)
|
||||
|
@ -308,6 +308,7 @@ class RepositoriesController < ApplicationController
|
|||
def raw
|
||||
domain = GiteaService.gitea_config[:domain]
|
||||
api_url = GiteaService.gitea_config[:base_url]
|
||||
tip_exception('不可访问') if params[:filepath].to_s.include?("chinese_dictionary.txt")
|
||||
|
||||
url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{CGI.escape(params[:filepath])}?ref=#{CGI.escape(params[:ref])}"
|
||||
file_path = [domain, api_url, url].join
|
||||
|
|
|
@ -9,7 +9,7 @@ class Users::OrganizationsController < Users::BaseController
|
|||
@organizations = observed_user.organizations.with_visibility("common")
|
||||
end
|
||||
|
||||
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
||||
@organizations = @organizations.ransack(login_or_nickname_cont: params[:search]).result if params[:search].present?
|
||||
|
||||
@home_top_ids = @organizations.joins(:home_top_settings).where(home_top_settings: {user_id: observed_user.id}).order("home_top_settings.created_at asc").pluck(:id)
|
||||
|
||||
|
|
|
@ -244,7 +244,9 @@ module RepositoriesHelper
|
|||
Rails.logger.info("entry===#{entry["type"]} #{entry["name"]}")
|
||||
content = entry['content'].present? ? entry['content'] : Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
|
||||
# readme_render_decode64_content(content, owner, repo, ref)
|
||||
new_readme_render_decode64_content(content, owner, repo, ref, entry['path'], entry['name'])
|
||||
text = new_readme_render_decode64_content(content, owner, repo, ref, entry['path'], entry['name'])
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
end
|
||||
|
||||
def decode64_content(entry, owner, repo, ref, path=nil)
|
||||
|
@ -253,9 +255,13 @@ module RepositoriesHelper
|
|||
content = entry['content'].present? ? entry['content'] : Gitea::Repository::Entries::GetService.call(owner, repo.identifier, URI.escape(entry['path']), ref: ref)['content']
|
||||
# Rails.logger.info("content===#{content}")
|
||||
return Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding?
|
||||
return Base64.decode64(content).force_encoding('UTF-8')
|
||||
text = Base64.decode64(content).force_encoding('UTF-8')
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
elsif entry['is_text_file'] == true
|
||||
return render_decode64_content(entry['content'])
|
||||
text = render_decode64_content(entry['content'])
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
else
|
||||
file_type = File.extname(entry['name'].to_s)[1..-1]
|
||||
if image_type?(file_type)
|
||||
|
@ -264,7 +270,9 @@ module RepositoriesHelper
|
|||
if download_type(file_type)
|
||||
return entry['content']
|
||||
end
|
||||
render_decode64_content(entry['content'])
|
||||
text = render_decode64_content(entry['content'])
|
||||
text = "该内容不合规,请修改。" if text.present? && !HarmoniousDictionary.clean?(text)
|
||||
text
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService
|
|||
param = {
|
||||
access_token: token,
|
||||
page: page,
|
||||
limit: limit
|
||||
limit: limit,
|
||||
stats: false,
|
||||
files: false
|
||||
}
|
||||
param.merge!(keyword: keyword) if keyword.present?
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ json.author do
|
|||
user = project.owner
|
||||
json.name user.try(:show_real_name)
|
||||
json.type user&.type
|
||||
json.login user&.login
|
||||
json.image_url url_to_avatar(user)
|
||||
json.login user.login
|
||||
json.image_url url_to_avatar(user).present? ? url_to_avatar(user) : User::Avatar.get_letter_avatar_url(user.login)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -638,7 +638,6 @@ a级情片
|
|||
法仑
|
||||
法伦
|
||||
法轮
|
||||
法论
|
||||
反封锁技术
|
||||
反腐败论坛
|
||||
反共
|
||||
|
@ -1252,7 +1251,6 @@ fa轮
|
|||
指点江山论坛
|
||||
中俄边界
|
||||
中功
|
||||
中共
|
||||
中国威胁论
|
||||
中国问题论坛
|
||||
中国之春
|
||||
|
|
Binary file not shown.
|
@ -98,6 +98,9 @@ defaults format: :json do
|
|||
patch :update_phone
|
||||
end
|
||||
end
|
||||
scope module: :organizations do
|
||||
resources :sync_repositories, only: [:create]
|
||||
end
|
||||
scope module: :users do
|
||||
resources :projects, only: [:index]
|
||||
resources :feedbacks, only: [:create]
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddProjectIndexGpid < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :projects, :gpid
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue