Merge pull request #3749 from riking/patch-1

FIX: Don't allow editing seeded category security settings
This commit is contained in:
Robin Ward 2015-09-11 12:22:58 -04:00
commit 4f5d42ca69
5 changed files with 32 additions and 10 deletions

View file

@ -7,16 +7,24 @@ export default buildCategoryPanel('security', {
actions: { actions: {
editPermissions() { editPermissions() {
if (!this.get('category.is_special')) {
this.set('editingPermissions', true); this.set('editingPermissions', true);
}
}, },
addPermission(group, id) { addPermission(group, id) {
this.get('category').addPermission({group_name: group + "", if (!this.get('category.is_special')) {
permission: Discourse.PermissionType.create({id})}); this.get('category').addPermission({
group_name: group + "",
permission: Discourse.PermissionType.create({id})
});
}
}, },
removePermission(permission) { removePermission(permission) {
if (!this.get('category.is_special')) {
this.get('category').removePermission(permission); this.get('category').removePermission(permission);
}
}, },
} }
}); });

View file

@ -1,4 +1,7 @@
<section class='field'> <section class='field'>
{{#if category.is_special}}
<p class="warning">{{i18n 'category.special_warning'}}</p>
{{/if}}
<ul class='permission-list'> <ul class='permission-list'>
{{#each category.permissions as |p|}} {{#each category.permissions as |p|}}
<li> <li>
@ -16,6 +19,8 @@
{{view 'select' class="permission-selector" optionValuePath="content.id" optionLabelPath="content.description" content=category.availablePermissions value=selectedPermission}} {{view 'select' class="permission-selector" optionValuePath="content.id" optionLabelPath="content.description" content=category.availablePermissions value=selectedPermission}}
<button {{action "addPermission" selectedGroup selectedPermission}} class="btn btn-small">{{i18n 'category.add_permission'}}</button> <button {{action "addPermission" selectedGroup selectedPermission}} class="btn btn-small">{{i18n 'category.add_permission'}}</button>
{{else}} {{else}}
{{#unless category.is_special}}
<button {{action "editPermissions"}} class="btn btn-small">{{i18n 'category.edit_permissions'}}</button> <button {{action "editPermissions"}} class="btn btn-small">{{i18n 'category.edit_permissions'}}</button>
{{/unless}}
{{/if}} {{/if}}
</section> </section>

View file

@ -11,6 +11,7 @@ class CategorySerializer < BasicCategorySerializer
:suppress_from_homepage, :suppress_from_homepage,
:can_delete, :can_delete,
:cannot_delete_reason, :cannot_delete_reason,
:is_special,
:allow_badges, :allow_badges,
:custom_fields :custom_fields
@ -37,6 +38,15 @@ class CategorySerializer < BasicCategorySerializer
true true
end end
def include_is_special?
[SiteSetting.lounge_category_id, SiteSetting.meta_category_id, SiteSetting.staff_category_id, SiteSetting.uncategorized_category_id]
.include? object.id
end
def is_special
true
end
def include_can_delete? def include_can_delete?
scope && scope.can_delete?(object) scope && scope.can_delete?(object)
end end

View file

@ -1539,6 +1539,7 @@ en:
change_in_category_topic: "Edit Description" change_in_category_topic: "Edit Description"
already_used: 'This color has been used by another category' already_used: 'This color has been used by another category'
security: "Security" security: "Security"
special_warning: "Warning: This category is a pre-seeded category and the security settings cannot be edited. If you do not wish to use this category, delete it instead of repurposing it."
images: "Images" images: "Images"
auto_close_label: "Auto-close topics after:" auto_close_label: "Auto-close topics after:"
auto_close_units: "hours" auto_close_units: "hours"

View file

@ -418,9 +418,6 @@ posting:
newuser_max_attachments: newuser_max_attachments:
client: true client: true
default: 0 default: 0
uncategorized_category_id:
default: -1
hidden: true
post_excerpt_maxlength: 300 post_excerpt_maxlength: 300
display_name_on_posts: display_name_on_posts:
client: true client: true
@ -929,14 +926,15 @@ uncategorized:
lounge_category_id: lounge_category_id:
default: -1 default: -1
hidden: true hidden: true
meta_category_id: meta_category_id:
default: -1 default: -1
hidden: true hidden: true
staff_category_id: staff_category_id:
default: -1 default: -1
hidden: true hidden: true
uncategorized_category_id:
default: -1
hidden: true
performance_report_topic_id: performance_report_topic_id:
default: -1 default: -1