Created
February 17, 2011 02:11
-
-
Save evolve2k/830804 to your computer and use it in GitHub Desktop.
CanCan Abilities for Arbiters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Abilities.rb:41 - Want some refactoring help | |
| # | |
| #Arbiters for a tournament can manage it | |
| if user && !user.admin? | |
| can [:read, :update, :destroy], Tournament, ['? in (select user_id from tournaments_users where tournament_id = tournaments.id) or tournaments.group_id in (select group_id from group_users where user_id = ? and role = \'Administrator\')', user.id, user.id] do |tournament| | |
| tournament && (tournament.arbiters.include?(user) || | |
| (tournament.group && tournament.group.administrators.include?(user))) | |
| end | |
| can [:manage], [Division, Round, Pairing, Entry] do |x| | |
| x && x.tournament && can?(:update, x.tournament) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment