work in progress, add fidelity to category group permissions (full, create posts, readonly)

This commit is contained in:
Sam
2013-07-14 11:24:16 +10:00
parent 8d947535a8
commit ecf17cfebb
38 changed files with 349 additions and 126 deletions

View File

@ -7,6 +7,7 @@ class Guardian
def staff?; false; end
def approved?; false; end
def secure_category_ids; []; end
def topic_create_allowed_category_ids; []; end
def has_trust_level?(level); false; end
end
@ -328,7 +329,7 @@ class Guardian
topic.deleted_at.nil? &&
# not secure, or I can see it
(not(topic.secure_category?) || can_see_category?(topic.category)) &&
(not(topic.read_restricted_category?) || can_see_category?(topic.category)) &&
# not private, or I am allowed (or an admin)
(not(topic.private_message?) || authenticated? && (topic.all_allowed_users.where(id: @user.id).exists? || is_admin?))
@ -340,7 +341,7 @@ class Guardian
end
def can_see_category?(category)
not(category.secure) || secure_category_ids.include?(category.id)
not(category.read_restricted) || secure_category_ids.include?(category.id)
end
def can_vote?(post, opts={})
@ -378,6 +379,10 @@ class Guardian
@secure_category_ids ||= @user.secure_category_ids
end
def topic_create_allowed_category_ids
@topic_create_allowed_category_ids ||= @user.topic_create_allowed_category_ids
end
private
def is_my_own?(obj)