<commit_before>class ExclusiveEventRule < RegistrationRule
  # you can only be signed up to one event that has this rule at a time
  
  def attendance_valid?(attendance, other_atts=nil)
    if attendance.is_staff
      return true
    end
    
    if other_atts
      return other_atts.none? do |other_att| 
        (!other_att.is_staff &&
        other_att.event.simultaneous_with?(attendance.event) &&
        other_att.event.registration_policy.rules.any? { |r| r.kind_of? ExclusiveEventRule })
      end
    end
    
    sametime = attendance.event.simultaneous_events
    
    Attendance.find_all_by_person_id(attendance.person.id).each do |a|
      if a.is_staff
        next
      end
      
      e = a.event
      if !sametime.include?(e)
        next
      end
      
      e.registration_policy.rules.each do |r|
        if r.kind_of? ExclusiveEventRule
          return false
        end
      end
    end
    
    return true
  end
  
  def error_message(attendance)
    return "That person is already registered for another event at that time."
  end
end
<commit_msg>Don't count parent event itself for exclusion<commit_after>class ExclusiveEventRule < RegistrationRule
  # you can only be signed up to one event that has this rule at a time
  
  def attendance_valid?(attendance, other_atts=nil)
    if attendance.is_staff
      return true
    end
    
    if other_atts
      return other_atts.none? do |other_att| 
        (!other_att.is_staff &&
        other_att.event.parent == attendance.event.parent &&
        other_att.event.simultaneous_with?(attendance.event) &&
        other_att.event.registration_policy.rules.any? { |r| r.kind_of? ExclusiveEventRule })
      end
    end
    
    sametime = attendance.event.simultaneous_events
    
    Attendance.find_all_by_person_id(attendance.person.id).each do |a|
      if a.is_staff
        next
      end
      
      e = a.event
      if !sametime.include?(e)
        next
      end
      
      e.registration_policy.rules.each do |r|
        if r.kind_of? ExclusiveEventRule
          return false
        end
      end
    end
    
    return true
  end
  
  def error_message(attendance)
    return "That person is already registered for another event at that time."
  end
end

{'fraction_non_alphanumeric': 0.06696230598669622, 'fraction_numerical': 0.0, 'mean_word_length': 2.2838427947598254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1988792', 'n_tokens_mistral': 692, 'n_tokens_neox': 699, 'n_words': 180}