FIX: Don't show the category edit button unless the user can edit the

category
This commit is contained in:
Robin Ward 2014-08-12 13:30:28 -04:00
parent c74550fbad
commit 36f081bf43
4 changed files with 13 additions and 4 deletions

View file

@ -28,7 +28,7 @@ export default function(filter, params) {
category: model,
filterMode: filterMode,
noSubcategories: params && params.no_subcategories,
canEditCategory: Discourse.User.currentProp('staff'),
canEditCategory: model.get('can_edit'),
canChangeCategoryNotificationLevel: Discourse.User.current()
});
},

View file

@ -66,7 +66,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
var opts = { category: model, filterMode: filterMode };
opts.noSubcategories = noSubcategories;
opts.canEditCategory = Discourse.User.currentProp('staff');
opts.canEditCategory = model.get('can_edit');
this.controllerFor('navigation/category').setProperties(opts);
return Discourse.TopList.find(filterMode).then(function(list) {

View file

@ -75,7 +75,7 @@ class Site
end
site = Site.new(guardian)
MultiJson.dump(SiteSerializer.new(site, root: false))
MultiJson.dump(SiteSerializer.new(site, root: false, scope: guardian))
end
end

View file

@ -14,7 +14,8 @@ class BasicCategorySerializer < ApplicationSerializer
:parent_category_id,
:notification_level,
:logo_url,
:background_url
:background_url,
:can_edit
def include_parent_category_id?
parent_category_id
@ -23,4 +24,12 @@ class BasicCategorySerializer < ApplicationSerializer
def description
object.uncategorized? ? SiteSetting.uncategorized_description : object.description
end
def can_edit
true
end
def include_can_edit?
scope && scope.can_edit?(object)
end
end