diff --git a/README.md b/README.md index e2c0097..2919a4c 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,12 @@ You should now be able to see the plugin list in Administration -> Plugins. * Edit issue recurrence * Delete issue recurrence (additionally requires the user to be a project member or administrator) +3. Within the Administration/Plugins/Recurring Tasks configuration page in Redmine, you have the following global configuration options: + a. Attribute issue journals to user id (optional) -- if blank, no journal notes will be added on recurrence; otherwise, this should be the numeric Redmine user id to which all recurring + journal entries will be tied to. This can be helpful if you want to create a placeholder user account and see all recurrence history within Redmine. + b. Display top menu? -- defaults to yes for historical purposes; whether (for Redmine administrators) and Recurring tasks menu option should be displayed on the top menu. + c. Reopen issue on recurrence? -- defaults to no for historical purposes; whether to re-open an issue (yes) or clone to a new issue (no) when the issue is due to recur + ## Upgrade or Migrate Plugin Please check the Release Notes (ReleaseNotes.md) for substantive or breaking changes. diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 7d7a341..e94e0bb 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -3,17 +3,20 @@ ## Features Requested * Option to 'predict' recurrences on calendar -- perhaps ghost the projected recurrences in ([#38](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/38)) -* Option to re-open recurring issue instead of creating a new issue, so all comments/information are stored in a single place ([#45](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/45)); ([#45](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/74)) * Option to enable recurrence on a per-project basis ([#36](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/36)) -* Configurable option to hide the "Recurring issues" link in the admin menu ([#54](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/54)) ## Known Issues -* No ability to view historic recurrences +* No ability to view all historic recurrences * Deleting an issue does not provide a warning about deleting associated recurrences ## Next Version (Develop Branch) +Done +* Configurable option to hide the "Recurring issues" link in the admin menu ([#54](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/54)) +* Option to re-open recurring issues instead of creating a new issue, so all comments/information are stored in a single place ([#45](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/45)); + ([#74](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/74)). + ## Version 1.5.0 (13 June 2015) * Backwards-compatibility to Redmine 2.2 by testing if issue.closed_on? method exists ([#49](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/36)) @@ -32,7 +35,7 @@ * Russian translation contributed by @box789 ([#30](https://github.com/nutso/redmine-plugin-recurring-tasks/pull/30)) * French translation contributed by @jbeauvois ([#35](https://github.com/nutso/redmine-plugin-recurring-tasks/pull/35)) -* Backward Rails syntax compatibility ([#29](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/29), [#34](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/34)) +* Backward Rails syntax compatibility ([#29](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/29)), [#34](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/34)) * Deleting the source issue for a recurrence deletes the recurrence ([#33](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/33)) * Recurrence checks for nil issue before attempting to recur ([#33](https://github.com/nutso/redmine-plugin-recurring-tasks/issues/33)) diff --git a/app/models/recurring_task.rb b/app/models/recurring_task.rb index 230d269..da23cdb 100644 --- a/app/models/recurring_task.rb +++ b/app/models/recurring_task.rb @@ -223,6 +223,10 @@ def next_scheduled_recurrence # whether a recurrence needs to be added def need_to_recur? + # ensuring we don't have an infinite loop + # if the setting is to reopen issues on recurrence, then if the issue is open, no recurrence is needed + return false if(Setting.plugin_recurring_tasks['reopen_issue'] == "1" && !issue.closed?) + # 41 # if(fixed_schedule and (previous_date_for_recurrence + recurrence_pattern) <= (Time.now.to_date + 1.day)) then true else issue.closed? end if fixed_schedule @@ -244,26 +248,38 @@ def recur_issue_if_needed! # Add more than one recurrence to 'catch up' if warranted (issue #10) - while need_to_recur? - new_issue = issue.copy + while need_to_recur? + new_issue = issue # default to existing issue + if Setting.plugin_recurring_tasks['reopen_issue'] != "1" + # duplicate issue + new_issue = issue.copy + end + + # if a journal user has been defined, create a journal + unless Setting.plugin_recurring_tasks['journal_attributed_to_user'].blank? + issue.init_journal(User.find(Setting.plugin_recurring_tasks['journal_attributed_to_user']), l(:label_recurring_task)) + end new_issue.due_date = next_scheduled_recurrence #41 previous_date_for_recurrence + recurrence_pattern new_issue.start_date = new_issue.due_date new_issue.done_ratio = 0 - if issue.tracker.respond_to?(:default_status) - # Redmine 3 - new_issue.status = issue.tracker.default_status # issue status is NOT automatically new, default is whatever the default status for new issues is - else - # Redmine 2 - new_issue.status = IssueStatus.default - end + new_issue.status = recurring_issue_default_status new_issue.save! - puts "Recurring #{issue.id}: #{issue.subj_date}, created #{new_issue.id}: #{new_issue.subj_date}" + puts "Recurring #{issue.id}: #{issue.subj_date}, created or reopened #{new_issue.id}: #{new_issue.subj_date}" self.issue = new_issue save! end end + def recurring_issue_default_status + # issue status is NOT automatically new, default is whatever the default status for new issues is + + # Redmine 3 + return issue.tracker.default_status if issue.tracker.respond_to?(:default_status) + # Redmine 2 + IssueStatus.default + end + #41 def recurrence_to_s modifier = (interval_unit == INTERVAL_MONTH) ? " #{interval_localized_modifier}" : "" diff --git a/app/views/settings/_recurring_tasks_settings.html.erb b/app/views/settings/_recurring_tasks_settings.html.erb new file mode 100644 index 0000000..ccf1dbf --- /dev/null +++ b/app/views/settings/_recurring_tasks_settings.html.erb @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + +
<%=l(:label_recurring_tasks_setting_journal_user)%>
<%=l(:label_recurring_tasks_setting_show_top_menu)%> + +
<%=l(:label_recurring_tasks_setting_reopen_issue)%> + +
diff --git a/config/locales/de.yml b/config/locales/de.yml index 3a50f73..4f7d278 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -35,3 +35,6 @@ de: recurring_task_created: "Wiederholung wurde hinzugefügt. " recurring_task_saved: "Wiederholung wurde gespeichert. " recurring_task_removed: "Wiederholung wurde entfernt. " + + # settings (admins) + label_recurring_tasks_setting_show_top_menu: "Hauptmenü anzeigen?" diff --git a/config/locales/en.yml b/config/locales/en.yml index 21066d6..7a92c8d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -41,9 +41,13 @@ en: month_modifier_dow_from_first: "on %{dows_from_bom} %{day_of_week}" month_modifier_dow_to_last: "on %{dows_to_eom} to last %{day_of_week}" - recurring_task_created: "Recurrence created. " recurring_task_saved: "Recurrence saved. " recurring_task_removed: "Recurrence removed. " help_add_general_recurring_task: "You may find it easier to add recurrence via the specific issue's page." + + # settings (admins) + label_recurring_tasks_setting_show_top_menu: "Display top menu?" + label_recurring_tasks_setting_reopen_issue: "Reopen issue on recurrence?" + label_recurring_tasks_setting_journal_user: "Attribute issue journals to user id:" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e7f449b..be98fa1 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -45,3 +45,6 @@ fr: recurring_task_created: "Planification créée. " recurring_task_saved: "Planification sauvegardé. " recurring_task_removed: "Planification supprimée. " + + # settings (admins) + label_recurring_tasks_setting_show_top_menu: "Afficher menu principal?" diff --git a/config/locales/ru.yml b/config/locales/ru.yml index de6e99b..561a9a3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -35,3 +35,6 @@ ru: recurring_task_created: "Повторяющаяся задача создана. " recurring_task_saved: "Повторяющаяся задача сохранена. " recurring_task_removed: "Повторяющаяся задача удалена. " + + # settings (admins) + label_recurring_tasks_setting_show_top_menu: "отобразить главное меню?" diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d20c94f..1f884d7 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -35,3 +35,6 @@ zh: recurring_task_created: "Recurrence created. " recurring_task_saved: "Recurrence saved. " recurring_task_removed: "Recurrence removed. " + + # settings (admins) + label_recurring_tasks_setting_show_top_menu: "显示顶部菜单?" diff --git a/init.rb b/init.rb index 6fa9be9..3b14f9c 100644 --- a/init.rb +++ b/init.rb @@ -10,10 +10,18 @@ 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. Supports Redmine 2.x and 3.x' - version '1.5.0' + version '1.6.0' + + # user-accessible global configuration + settings :default => { + 'show_top_menu' => "1", + 'reopen_issue' => "0", + 'journal_attributed_to_user' => 1 + }, :partial => 'settings/recurring_tasks_settings' + 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? } + menu.push :recurring_tasks, { :controller => 'recurring_tasks', :action => 'index' }, :caption => :label_recurring_tasks, :if => Proc.new { User.current.admin? && (Setting.plugin_recurring_tasks['show_top_menu'] == "1")} end # Permissions map to issue permissions (#12)