FIX 处理修改组织后导致不能创建项目的bug

This commit is contained in:
jasder 2021-09-10 22:46:48 +08:00
parent e594c72c43
commit 8c60ce1d76
2 changed files with 22 additions and 6 deletions

View File

@ -43,7 +43,8 @@ class Organizations::OrganizationsController < Organizations::BaseController
@organization.login = organization_params[:name] if organization_params[:name].present?
@organization.nickname = organization_params[:nickname] if organization_params[:nickname].present?
@organization.save!
@organization.organization_extension.update_attributes!(organization_params.except(:name, :nickname))
sync_organization_extension!
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
end
@ -97,4 +98,18 @@ class Organizations::OrganizationsController < Organizations::BaseController
%w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
end
def set_max_repo_creation
organization_params[:max_repo_creation].blank? ? -1 : organization_params[:max_repo_creation]
end
def organization_extension_params
organization_params
.except(:name, :nickname)
.merge(max_repo_creation: set_max_repo_creation)
end
def sync_organization_extension!
@organization.organization_extension.update_attributes!(organization_extension_params)
end
end

View File

@ -26,13 +26,14 @@ class Projects::CreateForm < BaseForm
end
def check_owner
@owner = Owner.find_by(id: user_id)
raise "user_id值无效." if user_id && owner.blank?
@project_owner = Owner.find_by(id: user_id)
raise "user_id值无效." if user_id && @project_owner.blank?
end
def check_max_repo_creation
return unless owner.is_a?(Organization)
return if owner.max_repo_creation <= -1
raise "已超过组织设置最大仓库数" if owner.max_repo_creation == owner.num_projects
return unless @project_owner.is_a?(Organization)
return if @project_owner.max_repo_creation <= -1
raise "已超过组织设置最大仓库数" if @project_owner.max_repo_creation == @project_owner.num_projects
end
end