<commit_before>class Ability
  include CanCan::Ability
  
  def initialize(person)
    alias_action [:show_description], :to => :read
    
    can :read, Event
    cannot :read, ProposedEvent
    can :read, Schedule, :published => true
    
    if person
      if person.admin?
        can :manage, :all
      else
        # TODO: generalize this to work with multiple event levels deep
        
        event_staff_conds = { :attendances => { :person_id => person.id, :is_staff => true } }
        
        can :manage, Event, event_staff_conds
        can :view_attendances, Event, :attendees_visible => true, :attendances => { :person_id => person.id }
        can :manage, Event, :parent => event_staff_conds
        
        can :manage, Schedule, :event => event_staff_conds
        can :manage, Schedule, :event => { :parent => event_staff_conds }
      
        can :manage, Attendance, :event => event_staff_conds
        can :manage, Attendance, :event => { :parent => event_staff_conds }
        can :read, Attendance, { |att| can? :view_attendances, att.try(:event) }
        
        can :create, ProposedEvent
        can :manage, ProposedEvent, :parent => event_staff_conds
        can [:read, :update, :destroy], ProposedEvent, :proposer_id => person.id
      end
    end
  end
end<commit_msg>oops no<commit_after>class Ability
  include CanCan::Ability
  
  def initialize(person)
    alias_action [:show_description], :to => :read
    
    can :read, Event
    cannot :read, ProposedEvent
    can :read, Schedule, :published => true
    
    if person
      if person.admin?
        can :manage, :all
      else
        # TODO: generalize this to work with multiple event levels deep
        
        event_staff_conds = { :attendances => { :person_id => person.id, :is_staff => true } }
        
        can :manage, Event, event_staff_conds
        can :view_attendances, Event, :attendees_visible => true, :attendances => { :person_id => person.id }
        can :manage, Event, :parent => event_staff_conds
        
        can :manage, Schedule, :event => event_staff_conds
        can :manage, Schedule, :event => { :parent => event_staff_conds }
      
        can :manage, Attendance, :event => event_staff_conds
        can :manage, Attendance, :event => { :parent => event_staff_conds }
        can :read, Attendance { |att| can? :view_attendances, att.try(:event) }
        
        can :create, ProposedEvent
        can :manage, ProposedEvent, :parent => event_staff_conds
        can [:read, :update, :destroy], ProposedEvent, :proposer_id => person.id
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1083875909613175, 'fraction_numerical': 0.0, 'mean_word_length': 2.6077348066298343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1418771', 'n_tokens_mistral': 806, 'n_tokens_neox': 799, 'n_words': 222}