A platform for community discussion. Free, open, simple.
UX: show which groups are missing permissions for parent category (#7252)
Maja Komel88128f1cedd0
diff --git a/app/models/category.rb b/app/models/category.rbindex a1e5771d6cd..767b35077e7 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -664,9 +664,12 @@ class Category < ActiveRecord::Basereturn if parent_groups.include?(Group[:everyone].id)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))+ endenddef subcategories_permissionsdiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 7357e960ecf..bfcbeb05039 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -590,7 +590,7 @@ en: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}'."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}'"cannot_delete:uncategorized: "This category is special. It is intended as a holding area for topics that have no category; it cannot be deleted."diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rbindex 18fbc066cad..b5412e394c8 100644--- a/spec/models/category_spec.rb+++ b/spec/models/category_spec.rb@@ -787,7 +787,7 @@ describe Category dosubcategory.set_permissions(group => :full, group2 => :readonly)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))endit "is valid if permissions are same or more restrictive" do@@ -819,7 +819,7 @@ describe Category doparent_category.set_permissions(group => :readonly)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))endit "is valid if subcategory permissions are same or more restrictive" do