[ADD]org team search, project teams add\remove, org can create field

[FIX]
This commit is contained in:
2021-02-04 17:03:56 +08:00
parent 4f6f257b37
commit 54204d4db8
12 changed files with 150 additions and 80 deletions

View File

@@ -18,6 +18,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
end
def show
@can_create_project = @organization.can_create_project?(current_user.id)
@is_admin = can_edit_org?
@is_member = @organization.is_member?(current_user.id)
end
@@ -60,15 +61,15 @@ class Organizations::OrganizationsController < Organizations::BaseController
private
def convert_image!
return unless params[:image].present?
max_size = EduSetting.get('upload_avatar_max_size').to_i || 2 * 1024 * 1024 # 2M
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
render_error('文件大小超过限制') if @image.size > max_size.to_i
else
image = params[:image].to_s.strip
return render_error('请上传正确的图片') if image.blank?
@image = Util.convert_base64_image(image, max_size: max_size)
@image = Util.convert_base64_image(image, max_size: max_size.to_i)
end
rescue Base64ImageConverter::Error => ex
render_error(ex.message)

View File

@@ -15,6 +15,18 @@ class Organizations::TeamsController < Organizations::BaseController
@teams = kaminari_paginate(@teams)
end
def search
tip_exception("请输入搜索关键词") if params[:search].nil?
if @organization.is_owner?(current_user) || current_user.admin?
@teams = @organization.teams
else
@teams = @organization.teams.joins(:team_users).where(team_users: {user_id: current_user.id})
end
@is_admin = can_edit_org?
@teams = @teams.ransack(name_cont: params[:search]).result if params[:search].present?
@teams = @teams.includes(:team_units, :team_users)
end
def show
@is_admin = can_edit_org?
@is_member = @team.is_member?(current_user.id)