Skip to content

v1.6.0 #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 14, 2015
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))

Expand Down
36 changes: 26 additions & 10 deletions app/models/recurring_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}" : ""
Expand Down
26 changes: 26 additions & 0 deletions app/views/settings/_recurring_tasks_settings.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<table>
<tbody>
<tr>
<th><%=l(:label_recurring_tasks_setting_journal_user)%></th>
<td><input type="text" id="journal_attributed_to_user" value="<%= settings['journal_attributed_to_user'] %>" name="settings[journal_attributed_to_user]"></td>
</tr>
<tr>
<th><%=l(:label_recurring_tasks_setting_show_top_menu)%></th>
<td>
<select name="settings[show_top_menu]">
<option value="1" <%= settings['show_top_menu'] == "1" ? "selected" : "" %>><%= l(:general_text_Yes) %></option>
<option value="0" <%= settings['show_top_menu'] != "1" ? "selected" : "" %>><%= l(:general_text_No) %></option>
</select>
</td>
</tr>
<tr>
<th><%=l(:label_recurring_tasks_setting_reopen_issue)%></th>
<td>
<select name="settings[reopen_issue]">
<option value="1" <%= settings['reopen_issue'] == "1" ? "selected" : "" %>><%= l(:general_text_Yes) %></option>
<option value="0" <%= settings['reopen_issue'] != "1" ? "selected" : "" %>><%= l(:general_text_No) %></option>
</select>
</td>
</tr>
</tbody>
</table>
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
6 changes: 5 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
3 changes: 3 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ ru:
recurring_task_created: "Повторяющаяся задача создана. "
recurring_task_saved: "Повторяющаяся задача сохранена. "
recurring_task_removed: "Повторяющаяся задача удалена. "

# settings (admins)
label_recurring_tasks_setting_show_top_menu: "отобразить главное меню?"
3 changes: 3 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "显示顶部菜单?"
12 changes: 10 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down