mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 10:25:47 +08:00
improve logic for mod category management
This commit is contained in:
parent
b7caa33841
commit
d08973d60e
@ -1,17 +1,27 @@
|
||||
#mixin for all guardian methods dealing with category permisions
|
||||
module CategoryGuardian
|
||||
|
||||
# Creating Method
|
||||
def can_create_category?(parent)
|
||||
is_admin? || (SiteSetting.allow_moderators_to_create_categories && is_moderator?)
|
||||
def can_create_category?(parent=nil)
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.allow_moderators_to_create_categories &&
|
||||
is_moderator?
|
||||
)
|
||||
end
|
||||
|
||||
# Editing Method
|
||||
def can_edit_category?(category)
|
||||
is_admin?
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.allow_moderators_to_create_categories &&
|
||||
is_moderator? &&
|
||||
can_see_category?(category)
|
||||
)
|
||||
end
|
||||
|
||||
def can_delete_category?(category)
|
||||
is_admin? &&
|
||||
can_edit_category?(category) &&
|
||||
category.topic_count == 0 &&
|
||||
!category.uncategorized? &&
|
||||
!category.has_children?
|
||||
|
Loading…
x
Reference in New Issue
Block a user