diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 17:47:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 17:47:17 +0000 |
commit | c27106d8595c4ce668ae95cff776be932a525a9e (patch) | |
tree | eb9d86d5db5dad323a5de1dba430465593041ec6 /app/models | |
parent | a19a0d7b9278ae8666971e5f004013ecaa3a9cf8 (diff) | |
download | redmine-c27106d8595c4ce668ae95cff776be932a525a9e.tar.gz redmine-c27106d8595c4ce668ae95cff776be932a525a9e.zip |
Added a new value for date filters: 'this week'
git-svn-id: http://redmine.rubyforge.org/svn/trunk@704 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/query.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/query.rb b/app/models/query.rb index c700242ed..87569fe08 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -36,6 +36,7 @@ class Query < ActiveRecord::Base ">t+" => :label_in_more_than, "t+" => :label_in, "t" => :label_today, + "w" => :label_this_week, ">t-" => :label_less_than_ago, "<t-" => :label_more_than_ago, "t-" => :label_ago, @@ -48,8 +49,8 @@ class Query < ActiveRecord::Base :list_status => [ "o", "=", "!", "c", "*" ], :list_optional => [ "=", "!", "!*", "*" ], :list_one_or_more => [ "*", "=" ], - :date => [ "<t+", ">t+", "t+", "t", ">t-", "<t-", "t-" ], - :date_past => [ ">t-", "<t-", "t-", "t" ], + :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ], + :date_past => [ ">t-", "<t-", "t-", "t", "w" ], :string => [ "=", "~", "!", "!~" ], :text => [ "~", "!~" ] } @@ -71,7 +72,7 @@ class Query < ActiveRecord::Base # filter requires one or more values (values_for(field) and !values_for(field).first.empty?) or # filter doesn't require any value - ["o", "c", "!*", "*", "t"].include? operator_for(field) + ["o", "c", "!*", "*", "t", "w"].include? operator_for(field) end if filters end @@ -238,6 +239,8 @@ class Query < ActiveRecord::Base sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] when "t" sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)] + when "w" + sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Time.now.at_beginning_of_week), connection.quoted_date(Time.now.next_week)] when "~" sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" when "!~" |