From 3f6b36096c33cdf581a3778b32d7847b84f7a760 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 29 Dec 2014 11:54:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0integer=5Fdone=E7=B1=BB=E5=9E=8B=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=88=E6=9A=82=E6=9C=AA=E7=94=A8=E4=B8=8A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/query.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/query.rb b/app/models/query.rb index 550047c57..19bd1bed5 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -173,6 +173,7 @@ class Query < ActiveRecord::Base :string => [ "=", "~", "!", "!~", "!*", "*" ], :text => [ "~", "!~", "!*", "*" ], :integer => [ "=", ">=", "<=", "><", "!*", "*" ], + :integer_done => [ "=", ">=", "<=", "><", "!*", "*" ], :float => [ "=", ">=", "<=", "><", "!*", "*" ], :relation => ["=", "=p", "=!p", "!p", "!*", "*"] } @@ -217,6 +218,8 @@ class Query < ActiveRecord::Base case type_for(field) when :integer add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^[+-]?\d+$/) } + when :integer_done + add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^[+-]?\d+$/) || (v.match(/^[+-]?\d+$/) && (v.to_i<0 || v.to_i> 100)) } when :float add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^[+-]?\d+(\.\d*)?$/) } when :date, :date_past @@ -602,6 +605,12 @@ class Query < ActiveRecord::Base else sql = "#{db_table}.#{db_field} = #{value.first.to_i}" end + when :integer_done + if is_custom_filter + sql = "(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) = #{value.first.to_i})" + else + sql = "#{db_table}.#{db_field} = #{value.first.to_i}" + end when :float if is_custom_filter sql = "(#{db_table}.#{db_field} <> '' AND CAST(CASE #{db_table}.#{db_field} WHEN '' THEN '0' ELSE #{db_table}.#{db_field} END AS decimal(30,3)) BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5})" From cd6508efa25d3d980e247d839272db377bcd4b27 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 29 Dec 2014 16:30:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 202a2ee91..ea1f9b770 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -62,6 +62,11 @@ :is_student_batch_homework => @is_student_batch_homework}%> + <% if @is_teacher %> + + <% end %>