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, '头像修改失败!')
|
||||
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
|
||||
@user = current_user
|
||||
end
|
||||
|
|
|
@ -147,6 +147,15 @@ module ApplicationHelper
|
|||
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图
|
||||
def banner_img(source_type)
|
||||
if File.exist?(disk_filename(source_type, "banner"))
|
||||
|
|
|
@ -7,7 +7,7 @@ module Notice
|
|||
config = Rails.application.config_for(:configuration).symbolize_keys!
|
||||
notice_config = config[:notice].symbolize_keys!
|
||||
raise 'notice config missing' if notice_config.blank?
|
||||
rescue => exception
|
||||
rescue => ex
|
||||
raise ex if Rails.env.production?
|
||||
|
||||
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!
|
||||
trace_config = config[:trace].symbolize_keys!
|
||||
raise 'trace config missing' if trace_config.blank?
|
||||
rescue => exception
|
||||
rescue => ex
|
||||
raise ex if Rails.env.production?
|
||||
|
||||
puts %Q{\033[33m [warning] gitea config or configuration.yml missing,
|
||||
|
|
|
@ -83,6 +83,10 @@ class Organization < Owner
|
|||
|
||||
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
|
||||
Cache::V2::OwnerCommonService.new(self.id).reset
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ class Organizations::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
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,
|
||||
location, repo_admin_change_team_access,
|
||||
visibility, max_repo_creation)
|
||||
|
|
|
@ -2,20 +2,14 @@ class Trace::ClientService < ApplicationService
|
|||
|
||||
def post(url, params={})
|
||||
puts "[trace][POST] request params: #{params}"
|
||||
conn.post do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
end
|
||||
conn.post(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def authed_post(token, url, params={})
|
||||
puts "[trace][POST] request params: #{params}"
|
||||
puts "[trace][POST] request token: #{token}"
|
||||
conn.post do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
req.headers['Authorization'] = token
|
||||
end
|
||||
conn.headers['Authorization'] = token
|
||||
conn.post(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def get(url, params={})
|
||||
|
@ -42,69 +36,42 @@ class Trace::ClientService < ApplicationService
|
|||
|
||||
def delete(url, params={})
|
||||
puts "[trace][DELETE] request params: #{params}"
|
||||
conn.delete do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
end
|
||||
conn.delete(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def authed_delete(token, url, params={})
|
||||
puts "[trace][DELETE] request params: #{params}"
|
||||
puts "[trace][DELETE] request token: #{token}"
|
||||
conn.delete do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
req.headers['Authorization'] = token
|
||||
end
|
||||
conn.headers['Authorization'] = token
|
||||
conn.delete(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def patch(url, params={})
|
||||
puts "[trace][PATCH] request params: #{params}"
|
||||
conn.patch do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
end
|
||||
conn.patch(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def authed_patch(token, url, params={})
|
||||
puts "[trace][PATCH] request params: #{params}"
|
||||
puts "[trace][PATCH] request token: #{token}"
|
||||
conn.patch do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
req.headers['Authorization'] = token
|
||||
end
|
||||
conn.headers['Authorization'] = token
|
||||
conn.patch(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def put(url, params={})
|
||||
puts "[trace][PUT] request params: #{params}"
|
||||
conn.put do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
end
|
||||
conn.put(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
def authed_put(token, url, params={})
|
||||
puts "[trace][PUT] request params: #{params}"
|
||||
puts "[trace][PUT] request token: #{token}"
|
||||
conn.put do |req|
|
||||
req.url full_url(url)
|
||||
req.body = params[:data].to_json
|
||||
req.headers['Authorization'] = token
|
||||
end
|
||||
conn.headers['Authorization'] = token
|
||||
conn.put(full_url(url), params[:data])
|
||||
end
|
||||
|
||||
private
|
||||
def conn
|
||||
@client ||= begin
|
||||
Faraday.new(url: domain) do |req|
|
||||
req.request :url_encoded
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.adapter Faraday.default_adapter
|
||||
end
|
||||
end
|
||||
|
||||
@client
|
||||
Faraday.new(url: domain)
|
||||
end
|
||||
|
||||
def base_url
|
||||
|
@ -138,6 +105,6 @@ class Trace::ClientService < ApplicationService
|
|||
|
||||
log_error(status, body)
|
||||
|
||||
return [body["code"], body["Data"], body["Error"]]
|
||||
return [body["code"], body["data"], body["error"]]
|
||||
end
|
||||
end
|
|
@ -45,6 +45,11 @@
|
|||
<li>
|
||||
<%= 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>
|
||||
<% if EduSetting.get("glcc_apply_informations_admin_url")%>
|
||||
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root') %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -225,6 +225,7 @@ Rails.application.routes.draw do
|
|||
get :fan_users
|
||||
get :hovercard
|
||||
put :update_image
|
||||
get :get_image
|
||||
end
|
||||
collection do
|
||||
post :following
|
||||
|
|
Loading…
Reference in New Issue