FIX: Don't show the category edit button unless the user can edit the
category
This commit is contained in:
parent
c74550fbad
commit
36f081bf43
|
@ -28,7 +28,7 @@ export default function(filter, params) {
|
||||||
category: model,
|
category: model,
|
||||||
filterMode: filterMode,
|
filterMode: filterMode,
|
||||||
noSubcategories: params && params.no_subcategories,
|
noSubcategories: params && params.no_subcategories,
|
||||||
canEditCategory: Discourse.User.currentProp('staff'),
|
canEditCategory: model.get('can_edit'),
|
||||||
canChangeCategoryNotificationLevel: Discourse.User.current()
|
canChangeCategoryNotificationLevel: Discourse.User.current()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,7 +66,7 @@ Discourse.DiscoveryTopCategoryRoute = Discourse.Route.extend(Discourse.OpenCompo
|
||||||
|
|
||||||
var opts = { category: model, filterMode: filterMode };
|
var opts = { category: model, filterMode: filterMode };
|
||||||
opts.noSubcategories = noSubcategories;
|
opts.noSubcategories = noSubcategories;
|
||||||
opts.canEditCategory = Discourse.User.currentProp('staff');
|
opts.canEditCategory = model.get('can_edit');
|
||||||
this.controllerFor('navigation/category').setProperties(opts);
|
this.controllerFor('navigation/category').setProperties(opts);
|
||||||
|
|
||||||
return Discourse.TopList.find(filterMode).then(function(list) {
|
return Discourse.TopList.find(filterMode).then(function(list) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Site
|
||||||
end
|
end
|
||||||
|
|
||||||
site = Site.new(guardian)
|
site = Site.new(guardian)
|
||||||
MultiJson.dump(SiteSerializer.new(site, root: false))
|
MultiJson.dump(SiteSerializer.new(site, root: false, scope: guardian))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,8 @@ class BasicCategorySerializer < ApplicationSerializer
|
||||||
:parent_category_id,
|
:parent_category_id,
|
||||||
:notification_level,
|
:notification_level,
|
||||||
:logo_url,
|
:logo_url,
|
||||||
:background_url
|
:background_url,
|
||||||
|
:can_edit
|
||||||
|
|
||||||
def include_parent_category_id?
|
def include_parent_category_id?
|
||||||
parent_category_id
|
parent_category_id
|
||||||
|
@ -23,4 +24,12 @@ class BasicCategorySerializer < ApplicationSerializer
|
||||||
def description
|
def description
|
||||||
object.uncategorized? ? SiteSetting.uncategorized_description : object.description
|
object.uncategorized? ? SiteSetting.uncategorized_description : object.description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_edit
|
||||||
|
true
|
||||||
|
end
|
||||||
|
def include_can_edit?
|
||||||
|
scope && scope.can_edit?(object)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue