Browse Source

[FIX]show teams, org name valid message

tags/v3.0.1
viletyy 5 years ago
parent
commit
ec1acde99a
3 changed files with 10 additions and 4 deletions
  1. +4
    -4
      app/controllers/organizations/teams_controller.rb
  2. +4
    -0
      app/models/organization.rb
  3. +2
    -0
      config/locales/zh-CN.yml

+ 4
- 4
app/controllers/organizations/teams_controller.rb 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)



+ 4
- 0
app/models/organization.rb 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


+ 2
- 0
config/locales/zh-CN.yml View File

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


Loading…
Cancel
Save