UX: show which groups are missing permissions for parent category (#7252)
This commit is contained in:
parent
16215f9d3b
commit
88128f1ced
|
@ -664,9 +664,12 @@ class Category < ActiveRecord::Base
|
||||||
return if parent_groups.include?(Group[:everyone].id)
|
return if parent_groups.include?(Group[:everyone].id)
|
||||||
|
|
||||||
child_groups = child_permissions.map(&:first)
|
child_groups = child_permissions.map(&:first)
|
||||||
only_in_subcategory = child_groups - parent_groups
|
only_subcategory_groups = child_groups - parent_groups
|
||||||
|
|
||||||
errors.add(:base, I18n.t("category.errors.permission_conflict")) if only_in_subcategory.present?
|
if only_subcategory_groups.present?
|
||||||
|
group_names = Group.where(id: only_subcategory_groups).pluck(:name).join(", ")
|
||||||
|
errors.add(:base, I18n.t("category.errors.permission_conflict", group_names: group_names))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def subcategories_permissions
|
def subcategories_permissions
|
||||||
|
|
|
@ -590,7 +590,7 @@ en:
|
||||||
email_already_used_in_group: "'%{email}' is already used by the group '%{group_name}'."
|
email_already_used_in_group: "'%{email}' is already used by the group '%{group_name}'."
|
||||||
email_already_used_in_category: "'%{email}' is already used by the category '%{category_name}'."
|
email_already_used_in_category: "'%{email}' is already used by the category '%{category_name}'."
|
||||||
description_incomplete: "The category description post must have at least one paragraph."
|
description_incomplete: "The category description post must have at least one paragraph."
|
||||||
permission_conflict: "Any group that is allowed to access a subcategory must also be allowed to access the parent category."
|
permission_conflict: "Any group that is allowed to access a subcategory must also be allowed to access the parent category. The following groups have access to one of subcategories, but not to the parent category: %{group_names}."
|
||||||
disallowed_topic_tags: "This topic has tags not allowed by this category: '%{tags}'"
|
disallowed_topic_tags: "This topic has tags not allowed by this category: '%{tags}'"
|
||||||
cannot_delete:
|
cannot_delete:
|
||||||
uncategorized: "This category is special. It is intended as a holding area for topics that have no category; it cannot be deleted."
|
uncategorized: "This category is special. It is intended as a holding area for topics that have no category; it cannot be deleted."
|
||||||
|
|
|
@ -787,7 +787,7 @@ describe Category do
|
||||||
subcategory.set_permissions(group => :full, group2 => :readonly)
|
subcategory.set_permissions(group => :full, group2 => :readonly)
|
||||||
|
|
||||||
expect(subcategory.valid?).to eq(false)
|
expect(subcategory.valid?).to eq(false)
|
||||||
expect(subcategory.errors.full_messages).to eq([I18n.t("category.errors.permission_conflict")])
|
expect(subcategory.errors.full_messages).to contain_exactly(I18n.t("category.errors.permission_conflict", group_names: group2.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is valid if permissions are same or more restrictive" do
|
it "is valid if permissions are same or more restrictive" do
|
||||||
|
@ -819,7 +819,7 @@ describe Category do
|
||||||
parent_category.set_permissions(group => :readonly)
|
parent_category.set_permissions(group => :readonly)
|
||||||
|
|
||||||
expect(parent_category.valid?).to eq(false)
|
expect(parent_category.valid?).to eq(false)
|
||||||
expect(parent_category.errors.full_messages).to eq([I18n.t("category.errors.permission_conflict")])
|
expect(parent_category.errors.full_messages).to contain_exactly(I18n.t("category.errors.permission_conflict", group_names: group2.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is valid if subcategory permissions are same or more restrictive" do
|
it "is valid if subcategory permissions are same or more restrictive" do
|
||||||
|
|
Loading…
Reference in New Issue