[FIX]show teams, org name valid message

This commit is contained in:
viletyy 2021-02-05 15:06:13 +08:00
parent 55528950f1
commit ec1acde99a
3 changed files with 10 additions and 4 deletions

View File

@ -4,11 +4,11 @@ class Organizations::TeamsController < Organizations::BaseController
before_action :check_user_can_edit_org, only: [:create, :update, :destroy]
def index
if @organization.is_owner?(current_user) || current_user.admin?
#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
#else
# @teams = @organization.teams.joins(:team_users).where(team_users: {user_id: current_user.id})
#end
@is_admin = can_edit_org?
@teams = @teams.includes(:team_units, :team_users)

View File

@ -59,6 +59,9 @@
#
class Organization < Owner
alias_attribute :name, :login
NAME_REGEX = /^(?!_)(?!.*?_$)[a-zA-Z0-9_-]+$/ #只含有数字、字母、下划线不能以下划线开头和结尾
default_scope { where(type: "Organization") }
has_one :organization_extension, dependent: :destroy
@ -68,6 +71,7 @@ class Organization < Owner
validates :login, presence: true
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, case_sensitive: false
validates :login, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
delegate :description, :website, :location, :repo_admin_change_team_access,
:visibility, :max_repo_creation, :num_projects, :num_users, :num_teams, to: :organization_extension, allow_nil: true

View File

@ -61,6 +61,8 @@ zh-CN:
close_issue: 工单
activerecord:
attributes:
organization:
login: '组织名称'
user:
login: '登录名'
lastname: '姓名'