app/controllers/meetings_controller.rb
# Verifies that a meeting id is provided as parameter; otherwise
# return an invalid action request
# Assigns the meeting instance.
# Verifiy if user is logged and associated to a swimmer and sets preselection
# of team and swimmer
#
# == Params:
# id: the meeting id to be processed
#
Verifies that a meeting id is provided as parameter; otherwise
return an invalid action request
Assigns the meeting instance.
Verifiy if user is logged and associated to a swimmer and sets preselection
of team and swimmer

the meeting id to be processed
Verifies that a meeting id is provided as parameter ; otherwise return an invalid action request Assigns the meeting instance . Verifiy if user is logged and associated to a swimmer and sets preselection of team and swimmer the meeting id to be processed
def verify_meeting
    set_meeting_from_id
    unless ( @meeting )
      flash[:error] = I18n.t(:invalid_action_request) + ' - ' + I18n.t('meeting.errors.missing_meeting_id')
      redirect_to( meetings_current_path() ) and return
    end
    set_swimmer_from_current_user
    if @swimmer
      team = @swimmer.teams.joins(:badges).where(['badges.season_id = ?', @meeting.season_id]).first
      if @meeting.meeting_individual_results.where(['meeting_individual_results.swimmer_id = ?', @swimmer.id]).exists? ||
        @meeting.meeting_entries.where(['meeting_entries.swimmer_id = ?', @swimmer.id]).exists?
        @team = team
      else
        if team && (@meeting.meeting_individual_results.where(['meeting_individual_results.team_id = ?', team.id]).exists? ||
          @meeting.meeting_entries.where(['meeting_entries.team_id = ?', team.id]).exists?)
          @team = team
        end
      end
    end
  end
def verify_meeting set_meeting_from_id unless ( @meeting ) flash [ :error ] = I18n . t ( :invalid_action_request ) + ' - ' + I18n . t ( 'meeting.errors.missing_meeting_id' ) redirect_to ( meetings_current_path ( ) ) and return end set_swimmer_from_current_user if @swimmer team = @swimmer . teams . joins ( :badges ) . where ( [ 'badges.season_id = ?' , @meeting . season_id ] ) . first if @meeting . meeting_individual_results . where ( [ 'meeting_individual_results.swimmer_id = ?' , @swimmer . id ] ) . exists? || @meeting . meeting_entries . where ( [ 'meeting_entries.swimmer_id = ?' , @swimmer . id ] ) . exists? @team = team else if team && ( @meeting . meeting_individual_results . where ( [ 'meeting_individual_results.team_id = ?' , team . id ] ) . exists? || @meeting . meeting_entries . where ( [ 'meeting_entries.team_id = ?' , team . id ] ) . exists? ) @team = team end end end end
Verifies that a meeting id is provided as parameter; otherwise
return an invalid action request
Assigns the meeting instance.
Verifies that a meeting id is provided as parameter ; otherwise return an invalid action request Assigns the meeting instance .
# Find preselected team and swimmer if user logged in and associated to a swimmer # and the swimmer or team partecipated to the meeting # The team of the swimmer associated with the user parteciapte to the meeting