From 00275b79b16ad9eac071049d84606b4f39942d94 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 28 Mar 2011 18:59:22 +0200 Subject: some issues from vedrins tests fixed --- application.rb | 8 +++++--- views/layout.haml | 2 +- views/neighbors.haml | 1 - views/neighbors_navigation.haml | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/application.rb b/application.rb index fc21414..44adf89 100644 --- a/application.rb +++ b/application.rb @@ -70,7 +70,7 @@ get '/login' do end get '/models/?' do - @models = ToxCreateModel.all#.to_a.reverse + @models = ToxCreateModel.all.sort(:order => "DESC") subjectstring = session[:subjectid] ? "?subjectid=#{CGI.escape(session[:subjectid])}" : "" haml :models, :locals=>{:models=>@models, :subjectstring => subjectstring} end @@ -151,7 +151,7 @@ get '/model/:id/:view/?' do end get '/predict/?' do - @models = ToxCreateModel.all#.to_a.reverse + @models = ToxCreateModel.all.sort(:order => "DESC") @models = @models.collect{|m| m if m.status == 'Completed'}.compact haml :predict end @@ -201,7 +201,9 @@ post '/models' do # create a new model csv = params[:file][:tempfile].read @dataset.load_csv(csv, subjectid) when ".xls", ".xlsx" - @dataset.load_spreadsheet(Excel.new params[:file][:tempfile].path, subjectid) + excel_file = params[:file][:tempfile].path + File.extname(params[:file][:filename]) + File.rename(params[:file][:tempfile].path, excel_file) # add extension, spreadsheet does not read files without extensions + @dataset.load_spreadsheet(Excel.new excel_file, subjectid) else error "#{params[:file][:filename]} has a unsupported file type." end diff --git a/views/layout.haml b/views/layout.haml index d9d7783..cdabe43 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -37,7 +37,7 @@ - if `hostname`.match(/ot-test/) .notice This service is for testing purposes only - once a week all models will be deleted. Please send bug reports and feature requests to our - %a{:href => 'http://github.com/opentox/opentox-toxmodel/issues'} issue tracker. + %a{:href => 'http://github.com/opentox/toxcreate/issues'} issue tracker. - if flash[:notice] %p diff --git a/views/neighbors.haml b/views/neighbors.haml index 87fef13..b507da0 100644 --- a/views/neighbors.haml +++ b/views/neighbors.haml @@ -9,7 +9,6 @@ - first = 5*page - last = first+4 - neighbor_id = 0 --# LOGGER.debug neighbors.to_yaml - neighbors.sort{|a,b| b[OT.similarity] <=> a[OT.similarity]}[first..last].each do |neighbor| - neighbor_id += 1 - compound = OpenTox::Compound.new(neighbor[OT.compound]) diff --git a/views/neighbors_navigation.haml b/views/neighbors_navigation.haml index bf5ebb3..074b62c 100644 --- a/views/neighbors_navigation.haml +++ b/views/neighbors_navigation.haml @@ -8,7 +8,12 @@ #prev= "prev" unless @page.to_i == 0 - = "(#{5*@page+1}-#{5*@page+5}/#{@prediction.neighbors(@compound).size})" + - if @prediction.neighbors(@compound).size < 5*@page+5 + - last = @prediction.neighbors(@compound).size + - else + - last = 5*@page+5 + + = "(#{5*@page+1}-#{last}/#{@prediction.neighbors(@compound).size})" #next= "next" unless 5*@page.to_i+5 >= @prediction.neighbors(@compound).size -- cgit v1.2.3