FIX: Don't change automatic group name if localized name has been taken.

This commit is contained in:
Guo Xiang Tan
2017-01-18 12:20:23 +08:00
parent bfc52a8e6f
commit 59dfb51a35
2 changed files with 43 additions and 4 deletions

View File

@ -161,7 +161,13 @@ class Group < ActiveRecord::Base
# don't allow shoddy localization to break this
localized_name = I18n.t("groups.default_names.#{name}")
validator = UsernameValidator.new(localized_name)
group.name = validator.valid_format? ? localized_name : name
group.name =
if !Group.where(name: localized_name).exists? && validator.valid_format?
localized_name
else
name
end
# the everyone group is special, it can include non-users so there is no
# way to have the membership in a table