Revision 402fad5f
Added by Brad Buckingham almost 10 years ago
app/models/katello/concerns/organization_extensions.rb | ||
---|---|---|
|
||
# Ensure that the name and label namespaces do not overlap
|
||
def unique_name_and_label
|
||
if new_record? && Organization.where("name = ? OR label = ?", label, name).any?
|
||
if new_record? && Organization.where("name = ? OR label = ?", name, label).any?
|
||
errors.add(:organization, _("Names and labels must be unique across all organizations"))
|
||
elsif label_changed? && Organization.where("id != ? AND name = ?", id, label).any?
|
||
elsif label_changed? && Organization.where("id != ? AND label = ?", id, label).any?
|
||
errors.add(:label, _("Names and labels must be unique across all organizations"))
|
||
elsif name_changed? && Organization.where("id != ? AND label = ?", id, name).any?
|
||
elsif name_changed? && Organization.where("id != ? AND name = ?", id, name).any?
|
||
errors.add(:name, _("Names and labels must be unique across all organizations"))
|
||
else
|
||
true
|
Also available in: Unified diff
fixes #6550 / BZ 1117952 - fix issues with changing org name which affected running db:seed
Without these changes, the user cannot change the default organization
name and re-run 'rake db:seed'. The reason being, it would attempt
to create an organization with a label that was already in use and
the seed would fail.
In order to address this, this commit does a couple of things:
1. when creating an org, if a label is automatically generated
and it is already in use, re-generate the label using a uuid.
2. fix an existing validation which was incorrectly comparing
name=label, label=name, etc. during org create and update.