app/helpers/meeting_reservations_helper.rb
# Returns either a new *badge* reservation instance or an existing one when found
# (according to the parameters).
#
# Assumes all parameters are valid instances of the respective classes.
# (Returns a new empty instance in case of invalid parameters)
#
Returns either a new *badge* reservation instance or an existing one when found
(according to the parameters).

Assumes all parameters are valid instances of the respective classes.
(Returns a new empty instance in case of invalid parameters)
Returns either a new * badge * reservation instance or an existing one when found ( according to the parameters ) . Assumes all parameters are valid instances of the respective classes . ( Returns a new empty instance in case of invalid parameters )
def find_or_new_badge_reservation( current_user, meeting, team_affiliation, badge )
    return MeetingReservation.new unless current_user.instance_of?(User) &&
            meeting.instance_of?(Meeting) && team_affiliation.instance_of?(TeamAffiliation) &&
            badge.instance_of?(Badge)
    mr = MeetingReservation.where(
      meeting_id:       meeting.id,
      team_id:          team_affiliation.team_id,
      swimmer_id:       badge.swimmer_id,
      badge_id:         badge.id
    ).first
    if mr                                           
      mr
    else                                            
      MeetingReservation.new(
        meeting_id:       meeting.id,
        team_id:          team_affiliation.team_id,
        swimmer_id:       badge.swimmer_id,
        badge_id:         badge.id,
        user_id:          current_user.id,
        is_not_coming:    false,
        has_confirmed:    false
      )
    end
  end
def find_or_new_badge_reservation ( current_user , meeting , team_affiliation , badge ) return MeetingReservation . new unless current_user . instance_of? ( User ) && meeting . instance_of? ( Meeting ) && team_affiliation . instance_of? ( TeamAffiliation ) && badge . instance_of? ( Badge ) mr = MeetingReservation . where ( meeting_id : meeting . id , team_id : team_affiliation . team_id , swimmer_id : badge . swimmer_id , badge_id : badge . id ) . first if mr mr else MeetingReservation . new ( meeting_id : meeting . id , team_id : team_affiliation . team_id , swimmer_id : badge . swimmer_id , badge_id : badge . id , user_id : current_user . id , is_not_coming : false , has_confirmed : false ) end end
Returns either a new *badge* reservation instance or an existing one when found
(according to the parameters).
Returns either a new * badge * reservation instance or an existing one when found ( according to the parameters ) .
# Existing? # NEW?
current_user
<not_specific>
meeting
<not_specific>
team_affiliation
<not_specific>
badge
<not_specific>