fix: create team count limit
This commit is contained in:
parent
a7665df0ea
commit
47d1f727ce
|
@ -4,6 +4,14 @@ class Organizations::TeamsController < Organizations::BaseController
|
||||||
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
|
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
|
if params[:is_full].present?
|
||||||
|
if can_edit_org?
|
||||||
|
@teams = @organization.teams
|
||||||
|
else
|
||||||
|
@teams = []
|
||||||
|
end
|
||||||
|
else
|
||||||
#if @organization.is_owner?(current_user) || current_user.admin?
|
#if @organization.is_owner?(current_user) || current_user.admin?
|
||||||
@teams = @organization.teams
|
@teams = @organization.teams
|
||||||
#else
|
#else
|
||||||
|
@ -14,6 +22,7 @@ class Organizations::TeamsController < Organizations::BaseController
|
||||||
|
|
||||||
@teams = kaminari_paginate(@teams)
|
@teams = kaminari_paginate(@teams)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def search
|
def search
|
||||||
tip_exception("请输入搜索关键词") if params[:search].nil?
|
tip_exception("请输入搜索关键词") if params[:search].nil?
|
||||||
|
@ -34,9 +43,13 @@ class Organizations::TeamsController < Organizations::BaseController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
|
if @organization.teams.count >= 50
|
||||||
|
return render_forbidden("组织的团队数量已超过限制!")
|
||||||
|
else
|
||||||
Organizations::CreateTeamForm.new(team_params).validate!
|
Organizations::CreateTeamForm.new(team_params).validate!
|
||||||
@team = Organizations::Teams::CreateService.call(current_user, @organization, team_params)
|
@team = Organizations::Teams::CreateService.call(current_user, @organization, team_params)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
uid_logger_error(e.message)
|
uid_logger_error(e.message)
|
||||||
tip_exception(e.message)
|
tip_exception(e.message)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
json.id team.id
|
||||||
|
json.name team.name
|
||||||
|
json.nickname team.nickname.blank? ? team.name : team.nickname
|
|
@ -1,4 +1,8 @@
|
||||||
json.total_count @teams.total_count
|
json.total_count params[:is_full].present? ? @teams.count : @teams.total_count
|
||||||
json.teams @teams do |team|
|
json.teams @teams do |team|
|
||||||
|
if params[:is_full].present?
|
||||||
|
json.partial! "simple_detail", team: team, organization: @organization
|
||||||
|
else
|
||||||
json.partial! "detail", team: team, organization: @organization
|
json.partial! "detail", team: team, organization: @organization
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue