mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 05:35:46 +08:00
[FIX]组织上传头像支持多种格式、项目详情返回拥有者类型
[FIX] [FIX]
This commit is contained in:
@@ -31,4 +31,13 @@ class Organizations::BaseController < ApplicationController
|
||||
def project_mark
|
||||
params[:repo_name] || params[:id]
|
||||
end
|
||||
|
||||
private
|
||||
def limited_condition
|
||||
@organization.organization_extension.limited? && !current_user.logged?
|
||||
end
|
||||
|
||||
def privacy_condition
|
||||
@organization.organization_extension.privacy? && @organization.organization_users.where(user_id: current_user.id).blank?
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Organizations::OrganizationsController < Organizations::BaseController
|
||||
before_action :require_login, except: [:index, :show]
|
||||
before_action :convert_base64_image!, only: [:create, :update]
|
||||
before_action :convert_image!, only: [:create, :update]
|
||||
before_action :load_organization, only: [:show, :update, :destroy]
|
||||
before_action :check_user_can_edit_org, only: [:update, :destroy]
|
||||
|
||||
@@ -11,6 +11,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||
@organizations = Organization.from("( #{ logged_organizations_sql } UNION #{ privacy_organizations_sql } ) AS users")
|
||||
else
|
||||
@organizations = Organization.with_visibility("common")
|
||||
kaminari_paginate(@organizations)
|
||||
end
|
||||
@organizations = @organizations.ransack(login_cont: params[:search]).result if params[:search].present?
|
||||
@organizations = @organizations.includes(:organization_extension).order("organization_extensions.#{sort_by} #{sort_direction}")
|
||||
@@ -56,9 +57,17 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||
end
|
||||
|
||||
private
|
||||
def convert_base64_image!
|
||||
max_size = EduSetting.get('upload_avatar_max_size')
|
||||
@image = Util.convert_base64_image(params[:image].to_s.strip, max_size: max_size)
|
||||
def convert_image!
|
||||
max_size = EduSetting.get('upload_avatar_max_size') || 2 * 1024 * 1024 # 2M
|
||||
if params[:image].class == ActionDispatch::Http::UploadedFile
|
||||
@image = params[:image]
|
||||
render_error('请上传文件') if @image.size.zero?
|
||||
render_error('文件大小超过限制') if @image.size > max_size
|
||||
else
|
||||
image = params[:image].to_s.strip
|
||||
return render_error('请上传正确的图片') if image.blank?
|
||||
@image = Util.convert_base64_image(image, max_size: max_size)
|
||||
end
|
||||
rescue Base64ImageConverter::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user