REFACTOR: move all conditions to guardian

This commit is contained in:
Arpit Jalan
2014-07-04 23:04:19 +05:30
parent abf6ffcaa0
commit 48f86181bf
3 changed files with 16 additions and 5 deletions

View File

@ -200,9 +200,9 @@ class Guardian
end
def can_invite_to?(object, group_ids=nil)
can_see?(object) &&
can_invite_to_forum? &&
( group_ids.blank? || is_admin? )
can_invite = can_see?(object) && can_invite_to_forum? && ( group_ids.blank? || is_admin? )
can_invite = can_invite && ( !object.category.read_restricted || is_admin? ) if object.is_a?(Topic)
can_invite
end
def can_bulk_invite_to_forum?(user)