summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-09 17:40:00 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-09 17:40:00 +0000
commit3a178a42cfc05933dc876f875ff9aa45ffc794b5 (patch)
treed8bdd3873ce3542084acb856e9d1c552141db380
parent340b4a30d03e4b079724e02dc33bf1788a24a975 (diff)
downloadredmine-3a178a42cfc05933dc876f875ff9aa45ffc794b5.tar.gz
redmine-3a178a42cfc05933dc876f875ff9aa45ffc794b5.zip
Add "last 2 weeks" preset to time entries reporting (#11862).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10583 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/timelog_controller.rb3
-rw-r--r--app/helpers/timelog_helper.rb1
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/fr.yml1
-rw-r--r--test/functional/timelog_controller_test.rb7
5 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 7aae12b5c..1756758c6 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -308,6 +308,9 @@ private
when 'last_week'
@from = Date.today - 7 - (Date.today.cwday - 1)%7
@to = @from + 6
+ when 'last_2_weeks'
+ @from = Date.today - 14 - (Date.today.cwday - 1)%7
+ @to = @from + 13
when '7_days'
@from = Date.today - 7
@to = Date.today
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb
index 5642266b1..11a447660 100644
--- a/app/helpers/timelog_helper.rb
+++ b/app/helpers/timelog_helper.rb
@@ -77,6 +77,7 @@ module TimelogHelper
[l(:label_yesterday), 'yesterday'],
[l(:label_this_week), 'current_week'],
[l(:label_last_week), 'last_week'],
+ [l(:label_last_n_weeks, 2), 'last_2_weeks'],
[l(:label_last_n_days, 7), '7_days'],
[l(:label_this_month), 'current_month'],
[l(:label_last_month), 'last_month'],
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 60d0f3679..50373ed83 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -663,6 +663,7 @@ en:
label_yesterday: yesterday
label_this_week: this week
label_last_week: last week
+ label_last_n_weeks: "last %{count} weeks"
label_last_n_days: "last %{count} days"
label_this_month: this month
label_last_month: last month
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 353f99365..2aa9ab1ee 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -653,6 +653,7 @@ fr:
label_yesterday: hier
label_this_week: cette semaine
label_last_week: la semaine dernière
+ label_last_n_weeks: "les %{count} dernières semaines"
label_last_n_days: "les %{count} derniers jours"
label_this_month: ce mois-ci
label_last_month: le mois dernier
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 24893fdd0..2bc22a7ee 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -523,6 +523,13 @@ class TimelogControllerTest < ActionController::TestCase
assert_equal '2011-12-11'.to_date, assigns(:to)
end
+ def test_index_last_2_week
+ Date.stubs(:today).returns('2011-12-15'.to_date)
+ get :index, :period => 'last_2_weeks'
+ assert_equal '2011-11-28'.to_date, assigns(:from)
+ assert_equal '2011-12-11'.to_date, assigns(:to)
+ end
+
def test_index_7_days
Date.stubs(:today).returns('2011-12-15'.to_date)
get :index, :period => '7_days'