From ce183628dea4ef50e01bc90456c3f1938a5296be Mon Sep 17 00:00:00 2001 From: Teresa Date: Tue, 31 Dec 2013 07:38:31 -0500 Subject: [PATCH 01/51] added check for project (in case issue is deleted) --- app/views/recurring_tasks/index.html.erb | 3 ++- config/locales/de.yml | 2 ++ config/locales/en.yml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 1d16aa5..0e8df1a 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -19,7 +19,8 @@ <% @recurring_tasks.each do |rt| %> - <% if !@project %><%= link_to(rt.project, project_path(rt.project)) %><% end %> + + <% if !@project %><%= rt.project.nil? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> <%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_unit) %> <%= rt.fixed_schedule %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 52267d2..94a8b2b 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -7,6 +7,8 @@ de: label_no_recurring_tasks: "Keine wiederkehrenden Themen gefunden." label_next_scheduled_run: "Nächste Ausführung" label_no_recurrence: "Keine Wiederholung." + label_no_project: "Kein Projekt." + label_recurs_fixed: "nach einem festen Zeitplan" label_recurs_dependent: "nach Abschluss der vorherigen Durchführung" diff --git a/config/locales/en.yml b/config/locales/en.yml index cdfbb92..ca0fd91 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -7,6 +7,7 @@ en: label_no_recurring_tasks: "No recurring tasks found on the system." label_next_scheduled_run: "Next scheduled run" label_no_recurrence: "No recurrence." + label_no_project: "No project." label_recurs_fixed: "on a fixed schedule" label_recurs_dependent: "after previous task completion" From 88c7e79848142729fa784e01ef442acf8607b12b Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 11:35:04 -0500 Subject: [PATCH 02/51] ide files --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e6ca7d5..6cd7e65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -# Eclipse project file +# Eclipse project and settings files .project +.settings/* # OS generated files .DS_Store .DS_Store? From 807580265f06ee0e1eb0146140ddee7e741a9ec1 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 11:35:10 -0500 Subject: [PATCH 03/51] typo --- app/views/recurring_tasks/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 0e8df1a..da659fd 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -20,7 +20,7 @@ <% @recurring_tasks.each do |rt| %> - <% if !@project %><%= rt.project.nil? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> + <% if !@project %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> <%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_unit) %> <%= rt.fixed_schedule %> From c161c0f0b7f7437ced6bfd8cd723a6f0a75e6542 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 11:38:52 -0500 Subject: [PATCH 04/51] catching error when issue is deleted even though recurrence still exists --- lib/issues_patch.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/issues_patch.rb b/lib/issues_patch.rb index 7751516..767f338 100644 --- a/lib/issues_patch.rb +++ b/lib/issues_patch.rb @@ -4,7 +4,12 @@ def self.included(base) base.class_eval do # adding a property to issues that shows subject (date) that can be used in selecting issues def subj_date - "#{self.subject} (#{format_date self.due_date})" + begin + "#{self.subject} (#{format_date self.due_date})" + rescue + # TODO log info or whatnot if self is nil ... for some reason it still gets here + "" + end end #subj_date # whether this issue recurs From 32812ad2f90c44d025e6202fe6601a9720fa0a6c Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 11:40:33 -0500 Subject: [PATCH 05/51] backed out unnecessary error handling -- what i thought was happening actually wasn't --- lib/issues_patch.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/issues_patch.rb b/lib/issues_patch.rb index 767f338..7751516 100644 --- a/lib/issues_patch.rb +++ b/lib/issues_patch.rb @@ -4,12 +4,7 @@ def self.included(base) base.class_eval do # adding a property to issues that shows subject (date) that can be used in selecting issues def subj_date - begin - "#{self.subject} (#{format_date self.due_date})" - rescue - # TODO log info or whatnot if self is nil ... for some reason it still gets here - "" - end + "#{self.subject} (#{format_date self.due_date})" end #subj_date # whether this issue recurs From be9041007d0a4684895d4704fdba9e8742ed866c Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 11:43:51 -0500 Subject: [PATCH 06/51] checking for nil issue --- app/models/recurring_task.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index a62edd8..fd64957 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -94,6 +94,15 @@ def self.add_recurrences! # for a fixed schedule, this is the due date # for a relative schedule, this is the date closed def previous_date_for_recurrence - if fixed_schedule and !issue.due_date.nil? then issue.due_date elsif issue.closed_on.nil? then issue.updated_on else issue.closed_on end + if issue.nil? + logger.error "Issue is nil for recurrence #{id}." + Date.today + elsif fixed_schedule and !issue.due_date.nil? + issue.due_date + elsif issue.closed_on.nil? + issue.updated_on + else + issue.closed_on + end end end From c0e8d762a685b2b937611ac5a7cf8b25452221a9 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:02:38 -0500 Subject: [PATCH 07/51] updated notes with known issues --- ReleaseNotes.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 31653ed..8d981de 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,31 @@ # Recurring Tasks Redmine Plugin -- Release Notes +## Known Issues + +* (Confirmed) Changing the interval_day, interval_week, interval_month, or interval_year strings in the locale file, or changing locales, after adding recurrences generates an error +* (Confirmed) Deleting an issue does not delete the recurrence +* (Reported) Incompatibility with Redmine Stable 2.4 (#20) + +## Resolved for Next Version + +* After deleting an issue that still has a recurrence, recurrence views generate errors + +## Version 1.2.5 + +* resolved nil reference for fixed schedule recurrences with no due date (#16) +* includes german translation contributed by @skolarianer + +## Version 1.2.0 + +* more intuitive management within the issues themselves +* add link to add recurrence when viewing an issue (#7) +* display existing recurrence if application when viewing an issue (#6) + +## Version 1.1.0 + +* Project-specific recurring tasks view (#11) +* Better permissions (managed under issues) (#12) + ## Version 1.0.2 * Show next scheduled recurrence when displaying a recurring task (#9) @@ -9,7 +35,7 @@ ## Version 1.0.1 * Added missing translations -* Fixed missing routes +* Fixed missing routes (#1) ## Version 1.0.0 From aff42c680aaeaed6dd98630cf17fbb65ea627364 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:24:33 -0500 Subject: [PATCH 08/51] removing dependence on localized strings for day/week/month/year separation --- app/controllers/recurring_tasks_controller.rb | 2 +- app/models/recurring_task.rb | 72 +++++++++++++++++-- app/views/recurring_tasks/_form.html.erb | 2 +- app/views/recurring_tasks/index.html.erb | 2 +- app/views/recurring_tasks/show.html.erb | 2 +- 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/app/controllers/recurring_tasks_controller.rb b/app/controllers/recurring_tasks_controller.rb index 2ec8238..3b27ed1 100644 --- a/app/controllers/recurring_tasks_controller.rb +++ b/app/controllers/recurring_tasks_controller.rb @@ -83,6 +83,6 @@ def find_recurring_task end def set_interval_units - @interval_units = RecurringTask::INTERVAL_UNITS + @interval_units = RecurringTask::INTERVAL_UNITS_LOCALIZED end end diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index fd64957..ccb4a92 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -4,10 +4,19 @@ class RecurringTask < ActiveRecord::Base belongs_to :issue, :foreign_key => 'current_issue_id' has_one :project, through: :issue + attr_accessible :interval_localized_name + + # these are the flags used in the database to denote the interval + # the actual text displayed to the user is controlled in the language file + INTERVAL_DAY = 'd' + INTERVAL_WEEK = 'w' + INTERVAL_MONTH = 'm' + INTERVAL_YEAR = 'y' + # must come before validations otherwise unitialized - INTERVAL_UNITS = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] + INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] - validates :interval_unit, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS, message: "#{l(:error_invalid_interval)} %{value}" } + validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value}" } validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0} # cannot validate presence of issue if want to use other features # validates :issue, presence: true @@ -15,19 +24,68 @@ class RecurringTask < ActiveRecord::Base validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok + def interval_localized_name + case interval_unit + when INTERVAL_DAY + l(:interval_day) + when INTERVAL_WEEK + l(:interval_week) + when INTERVAL_MONTH + l(:interval_month) + when INTERVAL_YEAR + l(:interval_year) + else + logger.error "#{l(:error_invalid_interval)} %{interval_unit}" + end + end + + # text for the interval name + def interval_localized_name=(value) + interval_unit = case value + when l(:interval_day) + INTERVAL_DAY + when l(:interval_week) + INTERVAL_WEEK + when l(:interval_month) + INTERVAL_MONTH + when l(:interval_year) + INTERVAL_YEAR + else + logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize + "" + end + end + + # interval database name for the localized text + def self.interval_value interval + case interval + when l(:interval_day) + INTERVAL_DAY + when l(:interval_week) + INTERVAL_WEEK + when l(:interval_month) + INTERVAL_MONTH + when l(:interval_year) + INTERVAL_YEAR + else + logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize + "" + end + end + # time interval value of the recurrence pattern def recurrence_pattern case interval_unit - when l(:interval_day) + when INTERVAL_DAY interval_number.days - when l(:interval_week) + when INTERVAL_WEEK interval_number.weeks - when l(:interval_month) + when INTERVAL_MONTH interval_number.months - when l(:interval_year) + when INTERVAL_YEAR interval_number.years else - logger.error "Unsupported interval unit: #{interval_unit}" + logger.error "#{l(:error_invalid_interval)} %{interval_unit}" end end diff --git a/app/views/recurring_tasks/_form.html.erb b/app/views/recurring_tasks/_form.html.erb index 45ff17f..7e89490 100644 --- a/app/views/recurring_tasks/_form.html.erb +++ b/app/views/recurring_tasks/_form.html.erb @@ -4,7 +4,7 @@

<%= f.hidden_field :id %>

<%= label(:recurring_task, :current_issue_id, l(:field_issue)) %><%= collection_select('recurring_task', 'current_issue_id', @recurrable_issues, :id, :subj_date) %>

<%= f.number_field :interval_number %>

-

<%= label(:recurring_task, :interval_unit, l(:field_interval_unit)) %><%= select 'recurring_task', 'interval_unit', @interval_units %>

+

<%= label(:recurring_task, :interval_localized_name, l(:field_interval_unit)) %><%= select 'recurring_task', 'interval_localized_name', @interval_units %>

<%= f.check_box :fixed_schedule %>

<%= f.submit %>

<% end %> diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index da659fd..0447cea 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -22,7 +22,7 @@ <% if !@project %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> <%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> - <%= pluralize(rt.interval_number, rt.interval_unit) %> + <%= pluralize(rt.interval_number, rt.interval_localized_name) %> <%= rt.fixed_schedule %> <%= format_date(rt.next_scheduled_recurrence) %> <%= edit_button rt %> diff --git a/app/views/recurring_tasks/show.html.erb b/app/views/recurring_tasks/show.html.erb index 90af33e..ea26e04 100644 --- a/app/views/recurring_tasks/show.html.erb +++ b/app/views/recurring_tasks/show.html.erb @@ -4,7 +4,7 @@

<%= @recurring_task.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(@recurring_task.issue.subj_date, {:controller => 'issues', :action => 'show', :id => @recurring_task.issue.id}) %>

-

<%= l(:label_recurrence_pattern) %> <%= pluralize(@recurring_task.interval_number, @recurring_task.interval_unit) %>

+

<%= l(:label_recurrence_pattern) %> <%= pluralize(@recurring_task.interval_number, @recurring_task.interval_localized_name) %>

<%= @recurring_task.fixed_schedule ? l(:label_recurs_fixed) : l(:label_recurs_dependent) %>

<%= l(:label_next_scheduled_run) %>: <%= format_date(@recurring_task.next_scheduled_recurrence) %>

From 4f44004ceebebe544d15a0b163909d4cadef99d5 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:26:15 -0500 Subject: [PATCH 09/51] error message typo --- app/models/recurring_task.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index ccb4a92..d44dee7 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -16,7 +16,7 @@ class RecurringTask < ActiveRecord::Base # must come before validations otherwise unitialized INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] - validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value}" } + validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} #{value}" } validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0} # cannot validate presence of issue if want to use other features # validates :issue, presence: true @@ -35,7 +35,7 @@ def interval_localized_name when INTERVAL_YEAR l(:interval_year) else - logger.error "#{l(:error_invalid_interval)} %{interval_unit}" + logger.error "#{l(:error_invalid_interval)} #{interval_unit}" end end @@ -85,7 +85,7 @@ def recurrence_pattern when INTERVAL_YEAR interval_number.years else - logger.error "#{l(:error_invalid_interval)} %{interval_unit}" + logger.error "#{l(:error_invalid_interval)} #{interval_unit}" end end From 8e5b8f77f758eb028604294d697fbfdd8ae6e262 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:28:02 -0500 Subject: [PATCH 10/51] error message typo --- app/models/recurring_task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index d44dee7..ee60536 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -16,7 +16,7 @@ class RecurringTask < ActiveRecord::Base # must come before validations otherwise unitialized INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] - validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} #{value}" } + validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value}" } validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0} # cannot validate presence of issue if want to use other features # validates :issue, presence: true From 7f40e2a3232ff42e6da5463ba31cb2c851820f30 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:40:38 -0500 Subject: [PATCH 11/51] migrating the data in the database to match the non-localized values for interval unit --- ...andardize_recurrence_units_nonlocalized.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/migrate/002_standardize_recurrence_units_nonlocalized.rb diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb new file mode 100644 index 0000000..64d7a41 --- /dev/null +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -0,0 +1,26 @@ +# Previous to this migration, the value for recurring_tasks.interval_units +# was pulled from the localization file. +# This made the values more user-friendly when looking at the database directly +# however caused issues when the text changed, or locale changed. +# Here we are switching to just flags to denote the type of unit instead of text. +class StandardizeRecurrenceUnitsNonlocalized < ActiveRecord::Migration + def up + # TODO confirm with user until it's reversible + + RecurringTask.all.each do |rt| + begin + rt.interval_localized_name = rt.interval_unit + rescue + # TODO note error + end + end + end + + # There is no rolling back - this is a change to the DATA in the database, + # not to the structure itself. + # There is no guarantee that the current localized translation was the value + # previously in the database. + def down + raise ActiveRecord::IrreversibleMigration + end +end \ No newline at end of file From c9b6c5257567bfb80df0790295d990f2ac0131b0 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:41:46 -0500 Subject: [PATCH 12/51] logging --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 64d7a41..457fe7e 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -9,9 +9,10 @@ def up RecurringTask.all.each do |rt| begin + logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" rt.interval_localized_name = rt.interval_unit - rescue - # TODO note error + rescue => e + logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" end end end From 48890e0fbdb6be3802436c31e5b526b72498156c Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:43:42 -0500 Subject: [PATCH 13/51] saving changes --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 457fe7e..e62a254 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -11,6 +11,7 @@ def up begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" rt.interval_localized_name = rt.interval_unit + rt.save! rescue => e logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" end From 906a503eb86f56dcd7874a53fb3822956656da99 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:48:09 -0500 Subject: [PATCH 14/51] rolling back migration --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index e62a254..3bed9d5 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -23,6 +23,7 @@ def up # There is no guarantee that the current localized translation was the value # previously in the database. def down - raise ActiveRecord::IrreversibleMigration + # raise ActiveRecord::IrreversibleMigration + # TODO bring this back end end \ No newline at end of file From 547aae5531486ebfea06bc7b79f4df219cf27dc2 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:50:45 -0500 Subject: [PATCH 15/51] checking for nil --- app/views/recurring_tasks/index.html.erb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 0447cea..8bdbde7 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -20,7 +20,12 @@ <% @recurring_tasks.each do |rt| %> - <% if !@project %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> + <% + logger.info @project + logger.info rt.project + %> + + <% if !@project.nil? %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> <%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_localized_name) %> <%= rt.fixed_schedule %> From c6f093b9d2e2b251bba2a1c85853ed80a0312743 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:53:06 -0500 Subject: [PATCH 16/51] updated error messages to more clearly show where they were generated --- app/models/recurring_task.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index ee60536..17a4dd3 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -16,7 +16,7 @@ class RecurringTask < ActiveRecord::Base # must come before validations otherwise unitialized INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] - validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value}" } + validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value} (Validation)" } validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0} # cannot validate presence of issue if want to use other features # validates :issue, presence: true @@ -35,7 +35,7 @@ def interval_localized_name when INTERVAL_YEAR l(:interval_year) else - logger.error "#{l(:error_invalid_interval)} #{interval_unit}" + logger.error "#{l(:error_invalid_interval)} #{interval_unit} (interval_localized_name)" end end @@ -51,7 +51,7 @@ def interval_localized_name=(value) when l(:interval_year) INTERVAL_YEAR else - logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize + logger.error "Could not find matching value for localized interval name #{interval}. (interval_localized_name=)" # TODO localize "" end end @@ -68,7 +68,7 @@ def self.interval_value interval when l(:interval_year) INTERVAL_YEAR else - logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize + logger.error "Could not find matching value for localized interval name #{interval}. (self.interval_value)" # TODO localize "" end end @@ -85,7 +85,7 @@ def recurrence_pattern when INTERVAL_YEAR interval_number.years else - logger.error "#{l(:error_invalid_interval)} #{interval_unit}" + logger.error "#{l(:error_invalid_interval)} #{interval_unit} (recurrence_pattern)" end end From bdd37fd32013e1ac15f7649d8d3f9c83816fe096 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:56:30 -0500 Subject: [PATCH 17/51] returning an empty string so at least there are no type errors --- app/models/recurring_task.rb | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 17a4dd3..ec59100 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -24,6 +24,7 @@ class RecurringTask < ActiveRecord::Base validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok + # text for the interval name def interval_localized_name case interval_unit when INTERVAL_DAY @@ -36,10 +37,11 @@ def interval_localized_name l(:interval_year) else logger.error "#{l(:error_invalid_interval)} #{interval_unit} (interval_localized_name)" + "" end end - # text for the interval name + # interval database name for the localized text def interval_localized_name=(value) interval_unit = case value when l(:interval_day) @@ -56,23 +58,6 @@ def interval_localized_name=(value) end end - # interval database name for the localized text - def self.interval_value interval - case interval - when l(:interval_day) - INTERVAL_DAY - when l(:interval_week) - INTERVAL_WEEK - when l(:interval_month) - INTERVAL_MONTH - when l(:interval_year) - INTERVAL_YEAR - else - logger.error "Could not find matching value for localized interval name #{interval}. (self.interval_value)" # TODO localize - "" - end - end - # time interval value of the recurrence pattern def recurrence_pattern case interval_unit From dc3850d665937073da85fb6bad74c97e123ff53d Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 12:57:19 -0500 Subject: [PATCH 18/51] removed a space so definitely calling the right method --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 3bed9d5..201b9be 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -10,7 +10,7 @@ def up RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" - rt.interval_localized_name = rt.interval_unit + rt.interval_localized_name= rt.interval_unit rt.save! rescue => e logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" From f8d052a44e9435f734f2b4a3248b1b4be4e23092 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 13:00:27 -0500 Subject: [PATCH 19/51] skipping validation on save --- app/views/recurring_tasks/index.html.erb | 7 +------ .../002_standardize_recurrence_units_nonlocalized.rb | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 8bdbde7..0e1317a 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -19,12 +19,7 @@ <% @recurring_tasks.each do |rt| %> - - <% - logger.info @project - logger.info rt.project - %> - + <% if !@project.nil? %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><% end %> <%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_localized_name) %> diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 201b9be..6ca8761 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -10,8 +10,8 @@ def up RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" - rt.interval_localized_name= rt.interval_unit - rt.save! + rt.interval_localized_name = rt.interval_unit + rt.save!(:validate => false) rescue => e logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" end @@ -24,6 +24,6 @@ def up # previously in the database. def down # raise ActiveRecord::IrreversibleMigration - # TODO bring this back + # TODO bring thi sback end end \ No newline at end of file From 8b11556208b7e8e6bcfcab697d6b2353964a2532 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 13:00:38 -0500 Subject: [PATCH 20/51] removed a space so definitely calling the right method --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 6ca8761..34d0f68 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -10,7 +10,7 @@ def up RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" - rt.interval_localized_name = rt.interval_unit + rt.interval_localized_name= rt.interval_unit rt.save!(:validate => false) rescue => e logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" From 19c8b873dcfc91a8b269e7212a24e875f243a3ef Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 13:03:05 -0500 Subject: [PATCH 21/51] referencing generic conversion instead of object based --- app/models/recurring_task.rb | 17 +++++++++++++++++ ...standardize_recurrence_units_nonlocalized.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index ec59100..850fc16 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -58,6 +58,23 @@ def interval_localized_name=(value) end end + # used for migration #2 + def self.get_interval_localized_name(value) + case value + when l(:interval_day) + INTERVAL_DAY + when l(:interval_week) + INTERVAL_WEEK + when l(:interval_month) + INTERVAL_MONTH + when l(:interval_year) + INTERVAL_YEAR + else + logger.error "Could not find matching value for localized interval name #{interval}. (interval_localized_name=)" # TODO localize + "" + end + end + # time interval value of the recurrence pattern def recurrence_pattern case interval_unit diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 34d0f68..3229aeb 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -10,7 +10,7 @@ def up RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" - rt.interval_localized_name= rt.interval_unit + rt.interval_unit = RecurringTask.get_interval_localized_name(rt.interval_unit) rt.save!(:validate => false) rescue => e logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" From 2b06ffc95a40860da83e4290584780d1f57ee06c Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 13:07:53 -0500 Subject: [PATCH 22/51] always returning a date value --- app/models/recurring_task.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 850fc16..bb0c0b8 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -103,7 +103,12 @@ def self.all_for_project project # next due date for the task, if there is one (relative tasks won't have a next schedule until the current issue is closed) def next_scheduled_recurrence - previous_date_for_recurrence + recurrence_pattern unless previous_date_for_recurrence.nil? + if previous_date_for_recurrence.nil? + logger.error "Previous date for recurrence was nil for recurrence #{id}" # TODO localize + Date.today + else + previous_date_for_recurrence + recurrence_pattern + end end # whether a recurrence needs to be added From c3d4c16aaa0daec83bdc51cacb6518954c445840 Mon Sep 17 00:00:00 2001 From: Teresa Date: Wed, 1 Jan 2014 13:09:13 -0500 Subject: [PATCH 23/51] standardized project column display --- app/views/recurring_tasks/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 0e1317a..bb48096 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -8,7 +8,7 @@ - <% if !@project %><% end %> + <% if @project.nil? %><% end %> @@ -20,7 +20,7 @@ <% @recurring_tasks.each do |rt| %> - <% if !@project.nil? %><% end %> + <% if @project.nil? %><% end %> From 523bd0e7eb58a95b08053c244f5a68452d9bab96 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:00:22 -0500 Subject: [PATCH 24/51] localized more strings, updated en to refer to issues instead of tasks --- config/locales/en.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index ca0fd91..ad6f651 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,25 +1,26 @@ # English strings go here for Rails i18n en: - label_recurring_tasks: "Recurring Tasks" + label_recurring_tasks: "Recurring Issues" label_current_issue: "Current Issue for Recurrence" label_recurrence_pattern: "Recurs every" label_add_recurring_task: "Add Recurrence" - label_no_recurring_tasks: "No recurring tasks found on the system." + label_no_recurring_tasks: "No recurring issues found on the system." label_next_scheduled_run: "Next scheduled run" label_no_recurrence: "No recurrence." label_no_project: "No project." label_recurs_fixed: "on a fixed schedule" - label_recurs_dependent: "after previous task completion" + label_recurs_dependent: "after previous issue completion" label_recurring_task_issue_empty: "N/A" + label_recurring_task_project_empty: "N/A" label_belongs_to_project: "Belongs to project" label_assigned_to: "Assigned to" error_invalid_interval: "Interval provided is invalid." - error_recurring_task_not_found: "Could not find recurring task. " - error_recurring_task_could_not_remove: "Could not remove recurrence from task. " + error_recurring_task_not_found: "Could not find recurring issue. " + error_recurring_task_could_not_remove: "Could not remove recurrence from issue. " field_interval_number: "Interval number" field_interval_unit: "Interval Unit(s)" From 8446fbd568b19e290b4a97299ee73f467e1c04f3 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:00:37 -0500 Subject: [PATCH 25/51] (#21) localized menu captions --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index 91d6055..b06af79 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ version '1.2.5' Redmine::MenuManager.map :top_menu do |menu| - menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => 'Recurring Issues', :if => Proc.new { User.current.admin? } # TODO localize string + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } end # Permissions map to issue permissions (#12) @@ -26,7 +26,7 @@ end # project-specific recurring tasks view (#11) - menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => 'Recurring Issues', :after => :new_issue, :param => :project_id # TODO localize string + menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => l(:label_recurring_tasks), :after => :new_issue, :param => :project_id # Send patches to models and controllers Rails.configuration.to_prepare do From 111f6cd4a5d528a2af20e25878ca6d8b34eb408c Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:02:49 -0500 Subject: [PATCH 26/51] localized messages --- app/models/recurring_task.rb | 6 +++--- app/views/recurring_tasks/index.html.erb | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index bb0c0b8..645929e 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -53,7 +53,7 @@ def interval_localized_name=(value) when l(:interval_year) INTERVAL_YEAR else - logger.error "Could not find matching value for localized interval name #{interval}. (interval_localized_name=)" # TODO localize + logger.error "#{l(:error_invalid_interval)} #{interval} (interval_localized_name=)" "" end end @@ -70,7 +70,7 @@ def self.get_interval_localized_name(value) when l(:interval_year) INTERVAL_YEAR else - logger.error "Could not find matching value for localized interval name #{interval}. (interval_localized_name=)" # TODO localize + logger.error "#{l(:error_invalid_interval)} #{interval} (interval_localized_name=)" "" end end @@ -104,7 +104,7 @@ def self.all_for_project project # next due date for the task, if there is one (relative tasks won't have a next schedule until the current issue is closed) def next_scheduled_recurrence if previous_date_for_recurrence.nil? - logger.error "Previous date for recurrence was nil for recurrence #{id}" # TODO localize + logger.error "Previous date for recurrence was nil for recurrence #{id}" Date.today else previous_date_for_recurrence + recurrence_pattern diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index bb48096..551a89f 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -19,8 +19,7 @@ <% @recurring_tasks.each do |rt| %> - - <% if @project.nil? %><% end %> + <% if @project.nil? %><% end %> From f3580d9a20ecccb69e6f73441786dedefc5bbb64 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:06:12 -0500 Subject: [PATCH 27/51] error messages and TODOs --- .../002_standardize_recurrence_units_nonlocalized.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index 3229aeb..ddd14da 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -5,15 +5,15 @@ # Here we are switching to just flags to denote the type of unit instead of text. class StandardizeRecurrenceUnitsNonlocalized < ActiveRecord::Migration def up - # TODO confirm with user until it's reversible - RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" rt.interval_unit = RecurringTask.get_interval_localized_name(rt.interval_unit) rt.save!(:validate => false) rescue => e - logger.error "Migrating task ##{rt.id} from #{rt.interval_unit} FAILED. #{e}" + msg = "Migration for recurrence FAILED. ##{rt.id} from #{rt.interval_unit} FAILED. You will need to update this manually. #{e}" # TODO localize + logger.error msg + say msg # also display to user end end end @@ -23,7 +23,6 @@ def up # There is no guarantee that the current localized translation was the value # previously in the database. def down - # raise ActiveRecord::IrreversibleMigration - # TODO bring thi sback + raise ActiveRecord::IrreversibleMigration end end \ No newline at end of file From 9637b7b00c6c9a6d730287e35c678dd45a1730ce Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:06:25 -0500 Subject: [PATCH 28/51] updated known issues and resolved for next version --- ReleaseNotes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 8d981de..bd1d399 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,13 +2,15 @@ ## Known Issues -* (Confirmed) Changing the interval_day, interval_week, interval_month, or interval_year strings in the locale file, or changing locales, after adding recurrences generates an error -* (Confirmed) Deleting an issue does not delete the recurrence +* (Confirmed) Deleting an issue neither generates a warning nor deletes the recurrence * (Reported) Incompatibility with Redmine Stable 2.4 (#20) +* (Confirmed) No ability to view historic recurrences ## Resolved for Next Version * After deleting an issue that still has a recurrence, recurrence views generate errors +* Menu captions not localized (#21) +* Changing the interval_day, interval_week, interval_month, or interval_year strings in the locale file, or changing locales, after adding recurrences generates an error ## Version 1.2.5 From 32c2fff4c5f4af20cabda3271d112d621e5e2641 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:13:34 -0500 Subject: [PATCH 29/51] l function not available at init --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index b06af79..69f3498 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ version '1.2.5' Redmine::MenuManager.map :top_menu do |menu| - menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } end # Permissions map to issue permissions (#12) @@ -26,7 +26,7 @@ end # project-specific recurring tasks view (#11) - menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => l(:label_recurring_tasks), :after => :new_issue, :param => :project_id + menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.l(:label_recurring_tasks), :after => :new_issue, :param => :project_id # Send patches to models and controllers Rails.configuration.to_prepare do From dbfd4061f26fd8546348bb1f6965eb9d1eea8d17 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:14:31 -0500 Subject: [PATCH 30/51] using t instead of l --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index 69f3498..a83dfe2 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ version '1.2.5' Redmine::MenuManager.map :top_menu do |menu| - menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.t(:label_recurring_tasks), :if => Proc.new { User.current.admin? } end # Permissions map to issue permissions (#12) @@ -26,7 +26,7 @@ end # project-specific recurring tasks view (#11) - menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.l(:label_recurring_tasks), :after => :new_issue, :param => :project_id + menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.t(:label_recurring_tasks), :after => :new_issue, :param => :project_id # Send patches to models and controllers Rails.configuration.to_prepare do From 1ae47a970bc63f7293726e3b5d0b2271f25afb68 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:15:16 -0500 Subject: [PATCH 31/51] saying irreversible instead of erroring out --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index ddd14da..cf89d53 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -23,6 +23,7 @@ def up # There is no guarantee that the current localized translation was the value # previously in the database. def down - raise ActiveRecord::IrreversibleMigration + say "ActiveRecord::IrreversibleMigration" + # raise ActiveRecord::IrreversibleMigration end end \ No newline at end of file From cafa50dd80d179eba2b08969e215e182f082f516 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:17:23 -0500 Subject: [PATCH 32/51] error message contained wrong variable name --- app/models/recurring_task.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 645929e..6a330b2 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -53,7 +53,7 @@ def interval_localized_name=(value) when l(:interval_year) INTERVAL_YEAR else - logger.error "#{l(:error_invalid_interval)} #{interval} (interval_localized_name=)" + logger.error "#{l(:error_invalid_interval)} #{value} (interval_localized_name=)" "" end end @@ -70,7 +70,7 @@ def self.get_interval_localized_name(value) when l(:interval_year) INTERVAL_YEAR else - logger.error "#{l(:error_invalid_interval)} #{interval} (interval_localized_name=)" + logger.error "#{l(:error_invalid_interval)} #{value} (interval_localized_name=)" "" end end From e0c3453e649a39b5c0833782b38654259fb9aa1e Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:17:36 -0500 Subject: [PATCH 33/51] added marker for error --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index cf89d53..c0a7b79 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -11,7 +11,7 @@ def up rt.interval_unit = RecurringTask.get_interval_localized_name(rt.interval_unit) rt.save!(:validate => false) rescue => e - msg = "Migration for recurrence FAILED. ##{rt.id} from #{rt.interval_unit} FAILED. You will need to update this manually. #{e}" # TODO localize + msg = "Migration for recurrence FAILED. ##{rt.id} from #{rt.interval_unit} FAILED. You will need to update this manually. Error: #{e}" # TODO localize logger.error msg say msg # also display to user end From 643a55c7ddfd7abef5054a092137a17323b02c59 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:21:10 -0500 Subject: [PATCH 34/51] debugging --- app/views/recurring_tasks/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 551a89f..1ab4bef 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -18,6 +18,7 @@ <% @recurring_tasks.each do |rt| %> + <% logger.info rt.interval_number %> <% if @project.nil? %><% end %> From 7c8270a10f008aff6f90d185fa86b46701b94ffa Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:23:02 -0500 Subject: [PATCH 35/51] calling redmine's l method #21 --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index a83dfe2..0b83dcc 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ version '1.2.5' Redmine::MenuManager.map :top_menu do |menu| - menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.t(:label_recurring_tasks), :if => Proc.new { User.current.admin? } + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => Redmine::I18n.l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } end # Permissions map to issue permissions (#12) @@ -26,7 +26,7 @@ end # project-specific recurring tasks view (#11) - menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => I18n.t(:label_recurring_tasks), :after => :new_issue, :param => :project_id + menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => Redmine::I18n.l(:label_recurring_tasks), :after => :new_issue, :param => :project_id # Send patches to models and controllers Rails.configuration.to_prepare do From 3e98a5ca0a016658aa9f6f92b7e8308fd1b3998e Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:26:40 -0500 Subject: [PATCH 36/51] using nonlocalized symbols #21 --- init.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.rb b/init.rb index 0b83dcc..a6779a7 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ version '1.2.5' Redmine::MenuManager.map :top_menu do |menu| - menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => Redmine::I18n.l(:label_recurring_tasks), :if => Proc.new { User.current.admin? } + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => :label_recurring_tasks, :if => Proc.new { User.current.admin? } end # Permissions map to issue permissions (#12) @@ -26,7 +26,7 @@ end # project-specific recurring tasks view (#11) - menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => Redmine::I18n.l(:label_recurring_tasks), :after => :new_issue, :param => :project_id + menu :project_menu, :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => :label_recurring_tasks, :after => :new_issue, :param => :project_id # Send patches to models and controllers Rails.configuration.to_prepare do From cb363d78ed84c57de3f036863101a4368f890e5e Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:28:31 -0500 Subject: [PATCH 37/51] checking for errors --- app/views/recurring_tasks/index.html.erb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 1ab4bef..06c5d01 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -18,15 +18,19 @@ <% @recurring_tasks.each do |rt| %> - <% logger.info rt.interval_number %> - - <% if @project.nil? %><% end %> - - - - - - + + <% begin %> + <% logger.info rt.id %> + <% if @project.nil? %><% end %> + + + + + + <% rescue => e %> + + <% end %> + <% end %>
<%= l(:field_project)%><%= l(:field_project)%><%= l(:label_current_issue)%> <%= l(:label_recurrence_pattern)%> <%= l(:field_fixed_schedule)%>
<%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_localized_name) %> <%= rt.fixed_schedule %>
<%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %><%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %> <%= pluralize(rt.interval_number, rt.interval_localized_name) %> <%= rt.fixed_schedule %>
<%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %>
<%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %><%= pluralize(rt.interval_number, rt.interval_localized_name) %><%= rt.fixed_schedule %><%= format_date(rt.next_scheduled_recurrence) %><%= edit_button rt %>
<%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %><%= pluralize(rt.interval_number, rt.interval_localized_name) %><%= rt.fixed_schedule %><%= format_date(rt.next_scheduled_recurrence) %><%= edit_button rt %><%= e %>
From f7927b7b1ab566dd0f23d8a570c2c35a9deb02e7 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:32:37 -0500 Subject: [PATCH 38/51] back to raising the exception --- db/migrate/002_standardize_recurrence_units_nonlocalized.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index c0a7b79..c596ef0 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -23,7 +23,7 @@ def up # There is no guarantee that the current localized translation was the value # previously in the database. def down - say "ActiveRecord::IrreversibleMigration" - # raise ActiveRecord::IrreversibleMigration + # say "ActiveRecord::IrreversibleMigration" + raise ActiveRecord::IrreversibleMigration end end \ No newline at end of file From dce1d235c71900c0ab79febaaf682c5d2fcaf9e8 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:34:10 -0500 Subject: [PATCH 39/51] default recurrence pattern --- app/models/recurring_task.rb | 1 + app/views/recurring_tasks/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 6a330b2..b2120f1 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -88,6 +88,7 @@ def recurrence_pattern interval_number.years else logger.error "#{l(:error_invalid_interval)} #{interval_unit} (recurrence_pattern)" + 1.years end end diff --git a/app/views/recurring_tasks/index.html.erb b/app/views/recurring_tasks/index.html.erb index 06c5d01..0b57f0c 100644 --- a/app/views/recurring_tasks/index.html.erb +++ b/app/views/recurring_tasks/index.html.erb @@ -28,7 +28,7 @@ <%= format_date(rt.next_scheduled_recurrence) %> <%= edit_button rt %> <% rescue => e %> - <%= e %> + <%= "ERROR: #{e}" %> <% end %> <% end %> From 344f819bcc4ed9f74d701abebb4b2a1fef98be80 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:41:39 -0500 Subject: [PATCH 40/51] better display of error value --- app/models/recurring_task.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index b2120f1..c0463c7 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -16,10 +16,9 @@ class RecurringTask < ActiveRecord::Base # must come before validations otherwise unitialized INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)] - validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value} (Validation)" } + validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} '%{value}' (Validation)" } validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0} - # cannot validate presence of issue if want to use other features - # validates :issue, presence: true + # validates :issue, presence: true # cannot validate presence of issue if want to use other features # validates :fixed_schedule # requiring presence requires true validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok From 5c1ca48f01cce6958efcfe9f14637f9d004bf3b7 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:42:25 -0500 Subject: [PATCH 41/51] added section to note known issues with develop branch --- ReleaseNotes.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index bd1d399..7a0fc3f 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,11 +1,15 @@ # Recurring Tasks Redmine Plugin -- Release Notes -## Known Issues +## Known Issues (Master) * (Confirmed) Deleting an issue neither generates a warning nor deletes the recurrence * (Reported) Incompatibility with Redmine Stable 2.4 (#20) * (Confirmed) No ability to view historic recurrences +## Known Issues (Develop) + +* Update recurrence does not save properly + ## Resolved for Next Version * After deleting an issue that still has a recurrence, recurrence views generate errors From d6bc4ae766b08bbf6e0b02948a54fa76e64e9610 Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 08:43:38 -0500 Subject: [PATCH 42/51] better organization for sections --- ReleaseNotes.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 7a0fc3f..dca1ffe 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,16 +1,18 @@ # Recurring Tasks Redmine Plugin -- Release Notes -## Known Issues (Master) +## Known Issues + +### Master (Stable) * (Confirmed) Deleting an issue neither generates a warning nor deletes the recurrence * (Reported) Incompatibility with Redmine Stable 2.4 (#20) * (Confirmed) No ability to view historic recurrences -## Known Issues (Develop) +### Develop * Update recurrence does not save properly -## Resolved for Next Version +## Resolved in Develop (Next Version) * After deleting an issue that still has a recurrence, recurrence views generate errors * Menu captions not localized (#21) From b00ed9bee0d0c2803e307e80d8492a5b6e9df13c Mon Sep 17 00:00:00 2001 From: Teresa Date: Thu, 2 Jan 2014 22:12:15 -0500 Subject: [PATCH 43/51] centralized interval name to interval conversion --- app/models/recurring_task.rb | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index c0463c7..a69f943 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -42,19 +42,7 @@ def interval_localized_name # interval database name for the localized text def interval_localized_name=(value) - interval_unit = case value - when l(:interval_day) - INTERVAL_DAY - when l(:interval_week) - INTERVAL_WEEK - when l(:interval_month) - INTERVAL_MONTH - when l(:interval_year) - INTERVAL_YEAR - else - logger.error "#{l(:error_invalid_interval)} #{value} (interval_localized_name=)" - "" - end + interval_unit = RecurringTask.get_interval_localized_name(value) end # used for migration #2 From 2e148c5ff2580350f98dc1b92a40af7ac9e429e3 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 13:47:48 -0500 Subject: [PATCH 44/51] setting interval from localized name before save --- app/models/recurring_task.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index a69f943..19cd310 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -4,6 +4,8 @@ class RecurringTask < ActiveRecord::Base belongs_to :issue, :foreign_key => 'current_issue_id' has_one :project, through: :issue + before_save :set_interval + attr_accessible :interval_localized_name # these are the flags used in the database to denote the interval @@ -42,6 +44,7 @@ def interval_localized_name # interval database name for the localized text def interval_localized_name=(value) + @interval_localized_name = value interval_unit = RecurringTask.get_interval_localized_name(value) end @@ -143,6 +146,12 @@ def self.add_recurrences! end # end add_recurrences private + def set_interval + if !@interval_localized_name.nil? + interval_unit = RecurringTask.get_interval_localized_name(@interval_localized_name) + end + end + # the date from which to recur # for a fixed schedule, this is the due date # for a relative schedule, this is the date closed From 58eb04dccff6c970155abf0347aa9aa238776103 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 13:49:51 -0500 Subject: [PATCH 45/51] debug statement and method renamed --- app/models/recurring_task.rb | 8 ++++++-- .../002_standardize_recurrence_units_nonlocalized.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 19cd310..f1285e4 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -44,12 +44,13 @@ def interval_localized_name # interval database name for the localized text def interval_localized_name=(value) + logger.info "setting localized name to #{value}" @interval_localized_name = value - interval_unit = RecurringTask.get_interval_localized_name(value) + interval_unit = RecurringTask.get_interval_from_localized_name(value) end # used for migration #2 - def self.get_interval_localized_name(value) + def self.get_interval_from_localized_name(value) case value when l(:interval_day) INTERVAL_DAY @@ -146,8 +147,11 @@ def self.add_recurrences! end # end add_recurrences private + # called before save def set_interval + logger.info "setting interval called" if !@interval_localized_name.nil? + logger.info "setting interval" interval_unit = RecurringTask.get_interval_localized_name(@interval_localized_name) end end diff --git a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb index c596ef0..59ba25a 100644 --- a/db/migrate/002_standardize_recurrence_units_nonlocalized.rb +++ b/db/migrate/002_standardize_recurrence_units_nonlocalized.rb @@ -8,7 +8,7 @@ def up RecurringTask.all.each do |rt| begin logger.info "Migrating task ##{rt.id} from #{rt.interval_unit}" - rt.interval_unit = RecurringTask.get_interval_localized_name(rt.interval_unit) + rt.interval_unit = RecurringTask.get_interval_from_localized_name(rt.interval_unit) rt.save!(:validate => false) rescue => e msg = "Migration for recurrence FAILED. ##{rt.id} from #{rt.interval_unit} FAILED. You will need to update this manually. Error: #{e}" # TODO localize From acbc7efaa70eeed3c0e42fff25a53c1c07ca165f Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 13:50:46 -0500 Subject: [PATCH 46/51] typo --- app/models/recurring_task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index f1285e4..70cd12e 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -152,7 +152,7 @@ def set_interval logger.info "setting interval called" if !@interval_localized_name.nil? logger.info "setting interval" - interval_unit = RecurringTask.get_interval_localized_name(@interval_localized_name) + interval_unit = RecurringTask.get_interval_from_localized_name(@interval_localized_name) end end From 5b9f3e782e8dc08d535aa27744b93f961d625097 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 13:51:59 -0500 Subject: [PATCH 47/51] debug statements --- app/models/recurring_task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 70cd12e..8b5561e 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -151,8 +151,8 @@ def self.add_recurrences! def set_interval logger.info "setting interval called" if !@interval_localized_name.nil? - logger.info "setting interval" interval_unit = RecurringTask.get_interval_from_localized_name(@interval_localized_name) + logger.info "interval set to #{interval_unit}" end end From decd5b72390938b3072fa797ce75a7e036959c33 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 14:00:05 -0500 Subject: [PATCH 48/51] setting interval before validation instead of before save --- app/models/recurring_task.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 8b5561e..ae35292 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -4,7 +4,7 @@ class RecurringTask < ActiveRecord::Base belongs_to :issue, :foreign_key => 'current_issue_id' has_one :project, through: :issue - before_save :set_interval + before_validation :set_interval attr_accessible :interval_localized_name @@ -151,7 +151,7 @@ def self.add_recurrences! def set_interval logger.info "setting interval called" if !@interval_localized_name.nil? - interval_unit = RecurringTask.get_interval_from_localized_name(@interval_localized_name) + interval_unit= RecurringTask.get_interval_from_localized_name(@interval_localized_name) logger.info "interval set to #{interval_unit}" end end From e07028f75bd2005036a96e518abeb8e14f548ddb Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 14:02:13 -0500 Subject: [PATCH 49/51] workaround to set interval despite update_attributes --- app/controllers/recurring_tasks_controller.rb | 2 +- app/models/recurring_task.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/recurring_tasks_controller.rb b/app/controllers/recurring_tasks_controller.rb index 3b27ed1..9bb7515 100644 --- a/app/controllers/recurring_tasks_controller.rb +++ b/app/controllers/recurring_tasks_controller.rb @@ -44,7 +44,7 @@ def edit def update logger.info "Updating recurring task #{params[:id]}" - if @recurring_task.update_attributes(params[:recurring_task]) + if @recurring_task.update_from_form(params[:recurring_task]) flash[:notice] = l(:recurring_task_saved) redirect_to :action => :show else diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index ae35292..7ad3bf2 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -25,6 +25,13 @@ class RecurringTask < ActiveRecord::Base validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok + # workaround to set inverval + def update_from_form params + attributes=params[:recurring_task] + set_interval + save + end + # text for the interval name def interval_localized_name case interval_unit From 6faf37ccaab97a900f8246b38e7c1c35cca630b9 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 14:17:42 -0500 Subject: [PATCH 50/51] recurrence interval saves --- app/controllers/recurring_tasks_controller.rb | 3 ++- app/models/recurring_task.rb | 23 +------------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/app/controllers/recurring_tasks_controller.rb b/app/controllers/recurring_tasks_controller.rb index 9bb7515..ec3ee21 100644 --- a/app/controllers/recurring_tasks_controller.rb +++ b/app/controllers/recurring_tasks_controller.rb @@ -44,7 +44,8 @@ def edit def update logger.info "Updating recurring task #{params[:id]}" - if @recurring_task.update_from_form(params[:recurring_task]) + params[:recurring_task][:interval_unit] = RecurringTask.get_interval_from_localized_name(params[:recurring_task][:interval_localized_name]) + if @recurring_task.update_attributes(params[:recurring_task]) flash[:notice] = l(:recurring_task_saved) redirect_to :action => :show else diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 7ad3bf2..dbaee01 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -4,10 +4,6 @@ class RecurringTask < ActiveRecord::Base belongs_to :issue, :foreign_key => 'current_issue_id' has_one :project, through: :issue - before_validation :set_interval - - attr_accessible :interval_localized_name - # these are the flags used in the database to denote the interval # the actual text displayed to the user is controlled in the language file INTERVAL_DAY = 'd' @@ -25,13 +21,6 @@ class RecurringTask < ActiveRecord::Base validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok - # workaround to set inverval - def update_from_form params - attributes=params[:recurring_task] - set_interval - save - end - # text for the interval name def interval_localized_name case interval_unit @@ -51,9 +40,8 @@ def interval_localized_name # interval database name for the localized text def interval_localized_name=(value) - logger.info "setting localized name to #{value}" @interval_localized_name = value - interval_unit = RecurringTask.get_interval_from_localized_name(value) + interval_unit= RecurringTask.get_interval_from_localized_name(value) end # used for migration #2 @@ -154,15 +142,6 @@ def self.add_recurrences! end # end add_recurrences private - # called before save - def set_interval - logger.info "setting interval called" - if !@interval_localized_name.nil? - interval_unit= RecurringTask.get_interval_from_localized_name(@interval_localized_name) - logger.info "interval set to #{interval_unit}" - end - end - # the date from which to recur # for a fixed schedule, this is the due date # for a relative schedule, this is the date closed From f109a65c8418e532653658dad948946bbd667a92 Mon Sep 17 00:00:00 2001 From: Teresa Date: Sat, 4 Jan 2014 14:19:13 -0500 Subject: [PATCH 51/51] Version 1.2.6 --- ReleaseNotes.md | 8 ++++++-- init.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index dca1ffe..9a4b08f 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -5,15 +5,19 @@ ### Master (Stable) * (Confirmed) Deleting an issue neither generates a warning nor deletes the recurrence -* (Reported) Incompatibility with Redmine Stable 2.4 (#20) +* (Reported) Incompatibility with Redmine Stable 2.4 (#20) -- possibly line feed issue * (Confirmed) No ability to view historic recurrences ### Develop -* Update recurrence does not save properly +* ## Resolved in Develop (Next Version) +* + +## Version 1.2.6 + * After deleting an issue that still has a recurrence, recurrence views generate errors * Menu captions not localized (#21) * Changing the interval_day, interval_week, interval_month, or interval_year strings in the locale file, or changing locales, after adding recurrences generates an error diff --git a/init.rb b/init.rb index a6779a7..96c4915 100644 --- a/init.rb +++ b/init.rb @@ -10,7 +10,7 @@ author_url 'https://github.com/nutso/' url 'https://github.com/nutso/redmine-plugin-recurring-tasks' description 'Allows you to set a task to recur on a regular schedule, or when marked complete, regenerate a new task due in the future. Plugin is based -- very loosely -- on the periodic tasks plugin published by Tanguy de Courson' - version '1.2.5' + version '1.2.6' Redmine::MenuManager.map :top_menu do |menu| menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => :label_recurring_tasks, :if => Proc.new { User.current.admin? }