app/controllers/misc_controller.rb
# #AJAX POST-only pace_test_2000
#
# Calculate and show swimmer training paces
#
AJAX POST-only pace_test_2000
Calculate and show swimmer training paces
AJAX POST - only pace_test_2000 Calculate and show swimmer training paces
def show_training_paces_2000
    if request.xhr? && request.post?                   
      test_type_code = params['test_type_code'] ? params['test_type_code'] : ''      
      test_date      = params['test_date'] ? params['test_date'] : Date.today      
      pool_type_id   = params['pool_type_id'] ? params['pool_type_id'].to_i : 0       
      minutes_swam   = params['minutes_swam'] ? params['minutes_swam'].to_i : 0
      seconds_swam   = params['seconds_swam'] ? params['seconds_swam'].to_i : 0
      hundreds_swam  = params['hundreds_swam'] ? params['hundreds_swam'].to_i : 0
      unless ( test_type_code.length > 0 ) &&  ( minutes_swam > 0 ) && ( pool_type_id && pool_type_id > 0 ) 
        @error_message = I18n.t('misc.dati_mancanti')
        return
      end
      unless ( minutes_swam > 20 )
        @error_message = I18n.t('misc.record_del_mondo_in_allenamento')
        return
      end
      if @error_message == nil
        @pool_type = PoolType.find( pool_type_id )
        @time_swam = Timing.new( hundreds_swam, seconds_swam, minutes_swam )
        stpc = SwimmerTrainingPaceCalculator.new( test_type_code, @time_swam )
        @base_pace = stpc.calculate_paces
        @stp = stpc.calculated_swimmer_paces
      end
    end
  end
def show_training_paces_2000 if request . xhr? && request . post? test_type_code = params [ 'test_type_code' ] ? params [ 'test_type_code' ] : '' test_date = params [ 'test_date' ] ? params [ 'test_date' ] : Date . today pool_type_id = params [ 'pool_type_id' ] ? params [ 'pool_type_id' ] . to_i : 0 minutes_swam = params [ 'minutes_swam' ] ? params [ 'minutes_swam' ] . to_i : 0 seconds_swam = params [ 'seconds_swam' ] ? params [ 'seconds_swam' ] . to_i : 0 hundreds_swam = params [ 'hundreds_swam' ] ? params [ 'hundreds_swam' ] . to_i : 0 unless ( test_type_code . length > 0 ) && ( minutes_swam > 0 ) && ( pool_type_id && pool_type_id > 0 ) @error_message = I18n . t ( 'misc.dati_mancanti' ) return end unless ( minutes_swam > 20 ) @error_message = I18n . t ( 'misc.record_del_mondo_in_allenamento' ) return end if @error_message == nil @pool_type = PoolType . find ( pool_type_id ) @time_swam = Timing . new ( hundreds_swam , seconds_swam , minutes_swam ) stpc = SwimmerTrainingPaceCalculator . new ( test_type_code , @time_swam ) @base_pace = stpc . calculate_paces @stp = stpc . calculated_swimmer_paces end end end
AJAX POST-only pace_test_2000
Calculate and show swimmer training paces
AJAX POST - only pace_test_2000 Calculate and show swimmer training paces
# DEBUG #    puts "\r\n*********** show_pace_test_2000 ***********" #    puts params.inspect # === AJAX POST: === #flash[:error] = I18n.t(:missing_request_parameter) #flash[:error] = I18n.t('misc.record_del_mondo_in_allenamento') #puts "\r\n- stp: " << @stp.inspect