Merge branch 'standalone_develop' into pre_trustie_server
This commit is contained in:
commit
121e04f751
|
@ -97,6 +97,13 @@ class UsersController < ApplicationController
|
||||||
render_error(-1, '头像修改失败!')
|
render_error(-1, '头像修改失败!')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_image
|
||||||
|
return render_not_found unless @user = User.find_by(login: params[:id]) || User.find_by_id(params[:id])
|
||||||
|
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
|
||||||
|
|
||||||
|
redirect_to Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(@user).to_s
|
||||||
|
end
|
||||||
|
|
||||||
def me
|
def me
|
||||||
@user = current_user
|
@user = current_user
|
||||||
end
|
end
|
||||||
|
|
|
@ -147,6 +147,15 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def url_to_avatar_with_platform_url(source)
|
||||||
|
platform_url = Rails.application.config_for(:configuration)['platform_url']
|
||||||
|
if platform_url
|
||||||
|
return Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(source).to_s
|
||||||
|
else
|
||||||
|
return url_to_avatar(source).to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# 主页banner图
|
# 主页banner图
|
||||||
def banner_img(source_type)
|
def banner_img(source_type)
|
||||||
if File.exist?(disk_filename(source_type, "banner"))
|
if File.exist?(disk_filename(source_type, "banner"))
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Notice
|
||||||
config = Rails.application.config_for(:configuration).symbolize_keys!
|
config = Rails.application.config_for(:configuration).symbolize_keys!
|
||||||
notice_config = config[:notice].symbolize_keys!
|
notice_config = config[:notice].symbolize_keys!
|
||||||
raise 'notice config missing' if notice_config.blank?
|
raise 'notice config missing' if notice_config.blank?
|
||||||
rescue => exception
|
rescue => ex
|
||||||
raise ex if Rails.env.production?
|
raise ex if Rails.env.production?
|
||||||
|
|
||||||
puts %Q{\033[33m [warning] gitea config or configuration.yml missing,
|
puts %Q{\033[33m [warning] gitea config or configuration.yml missing,
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Trace
|
||||||
config = Rails.application.config_for(:configuration).symbolize_keys!
|
config = Rails.application.config_for(:configuration).symbolize_keys!
|
||||||
trace_config = config[:trace].symbolize_keys!
|
trace_config = config[:trace].symbolize_keys!
|
||||||
raise 'trace config missing' if trace_config.blank?
|
raise 'trace config missing' if trace_config.blank?
|
||||||
rescue => exception
|
rescue => ex
|
||||||
raise ex if Rails.env.production?
|
raise ex if Rails.env.production?
|
||||||
|
|
||||||
puts %Q{\033[33m [warning] gitea config or configuration.yml missing,
|
puts %Q{\033[33m [warning] gitea config or configuration.yml missing,
|
||||||
|
|
|
@ -83,6 +83,10 @@ class Organization < Owner
|
||||||
|
|
||||||
after_save :reset_cache_data
|
after_save :reset_cache_data
|
||||||
|
|
||||||
|
def gitea_token
|
||||||
|
team_users.joins(:team).where(teams: {authorize: "owner"}).take&.user&.gitea_token
|
||||||
|
end
|
||||||
|
|
||||||
def reset_cache_data
|
def reset_cache_data
|
||||||
Cache::V2::OwnerCommonService.new(self.id).reset
|
Cache::V2::OwnerCommonService.new(self.id).reset
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_org_and_extension
|
def create_org_and_extension
|
||||||
@organization = Organization.build(params[:name], params[:nickname], user.gitea_token)
|
@organization = Organization.build(params[:name], params[:nickname])
|
||||||
org_extension = OrganizationExtension.build(organization.id, description, website,
|
org_extension = OrganizationExtension.build(organization.id, description, website,
|
||||||
location, repo_admin_change_team_access,
|
location, repo_admin_change_team_access,
|
||||||
visibility, max_repo_creation)
|
visibility, max_repo_creation)
|
||||||
|
|
|
@ -2,20 +2,14 @@ class Trace::ClientService < ApplicationService
|
||||||
|
|
||||||
def post(url, params={})
|
def post(url, params={})
|
||||||
puts "[trace][POST] request params: #{params}"
|
puts "[trace][POST] request params: #{params}"
|
||||||
conn.post do |req|
|
conn.post(full_url(url), params[:data])
|
||||||
req.url full_url(url)
|
|
||||||
req.body = params[:data].to_json
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def authed_post(token, url, params={})
|
def authed_post(token, url, params={})
|
||||||
puts "[trace][POST] request params: #{params}"
|
puts "[trace][POST] request params: #{params}"
|
||||||
puts "[trace][POST] request token: #{token}"
|
puts "[trace][POST] request token: #{token}"
|
||||||
conn.post do |req|
|
conn.headers['Authorization'] = token
|
||||||
req.url full_url(url)
|
conn.post(full_url(url), params[:data])
|
||||||
req.body = params[:data].to_json
|
|
||||||
req.headers['Authorization'] = token
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(url, params={})
|
def get(url, params={})
|
||||||
|
@ -42,69 +36,42 @@ class Trace::ClientService < ApplicationService
|
||||||
|
|
||||||
def delete(url, params={})
|
def delete(url, params={})
|
||||||
puts "[trace][DELETE] request params: #{params}"
|
puts "[trace][DELETE] request params: #{params}"
|
||||||
conn.delete do |req|
|
conn.delete(full_url(url), params[:data])
|
||||||
req.url full_url(url)
|
|
||||||
req.body = params[:data].to_json
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def authed_delete(token, url, params={})
|
def authed_delete(token, url, params={})
|
||||||
puts "[trace][DELETE] request params: #{params}"
|
puts "[trace][DELETE] request params: #{params}"
|
||||||
puts "[trace][DELETE] request token: #{token}"
|
puts "[trace][DELETE] request token: #{token}"
|
||||||
conn.delete do |req|
|
conn.headers['Authorization'] = token
|
||||||
req.url full_url(url)
|
conn.delete(full_url(url), params[:data])
|
||||||
req.body = params[:data].to_json
|
|
||||||
req.headers['Authorization'] = token
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def patch(url, params={})
|
def patch(url, params={})
|
||||||
puts "[trace][PATCH] request params: #{params}"
|
puts "[trace][PATCH] request params: #{params}"
|
||||||
conn.patch do |req|
|
conn.patch(full_url(url), params[:data])
|
||||||
req.url full_url(url)
|
|
||||||
req.body = params[:data].to_json
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def authed_patch(token, url, params={})
|
def authed_patch(token, url, params={})
|
||||||
puts "[trace][PATCH] request params: #{params}"
|
puts "[trace][PATCH] request params: #{params}"
|
||||||
puts "[trace][PATCH] request token: #{token}"
|
puts "[trace][PATCH] request token: #{token}"
|
||||||
conn.patch do |req|
|
conn.headers['Authorization'] = token
|
||||||
req.url full_url(url)
|
conn.patch(full_url(url), params[:data])
|
||||||
req.body = params[:data].to_json
|
|
||||||
req.headers['Authorization'] = token
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def put(url, params={})
|
def put(url, params={})
|
||||||
puts "[trace][PUT] request params: #{params}"
|
puts "[trace][PUT] request params: #{params}"
|
||||||
conn.put do |req|
|
conn.put(full_url(url), params[:data])
|
||||||
req.url full_url(url)
|
|
||||||
req.body = params[:data].to_json
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def authed_put(token, url, params={})
|
def authed_put(token, url, params={})
|
||||||
puts "[trace][PUT] request params: #{params}"
|
puts "[trace][PUT] request params: #{params}"
|
||||||
puts "[trace][PUT] request token: #{token}"
|
puts "[trace][PUT] request token: #{token}"
|
||||||
conn.put do |req|
|
conn.headers['Authorization'] = token
|
||||||
req.url full_url(url)
|
conn.put(full_url(url), params[:data])
|
||||||
req.body = params[:data].to_json
|
|
||||||
req.headers['Authorization'] = token
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def conn
|
def conn
|
||||||
@client ||= begin
|
Faraday.new(url: domain)
|
||||||
Faraday.new(url: domain) do |req|
|
|
||||||
req.request :url_encoded
|
|
||||||
req.headers['Content-Type'] = 'application/json'
|
|
||||||
req.adapter Faraday.default_adapter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@client
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def base_url
|
def base_url
|
||||||
|
@ -138,6 +105,6 @@ class Trace::ClientService < ApplicationService
|
||||||
|
|
||||||
log_error(status, body)
|
log_error(status, body)
|
||||||
|
|
||||||
return [body["code"], body["Data"], body["Error"]]
|
return [body["code"], body["data"], body["error"]]
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -45,6 +45,11 @@
|
||||||
<li>
|
<li>
|
||||||
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire') do %>
|
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire') do %>
|
||||||
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news') %></li>
|
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news') %></li>
|
||||||
|
<li>
|
||||||
|
<% if EduSetting.get("glcc_apply_informations_admin_url")%>
|
||||||
|
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root') %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -225,6 +225,7 @@ Rails.application.routes.draw do
|
||||||
get :fan_users
|
get :fan_users
|
||||||
get :hovercard
|
get :hovercard
|
||||||
put :update_image
|
put :update_image
|
||||||
|
get :get_image
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
post :following
|
post :following
|
||||||
|
|
Loading…
Reference in New Issue