diff --git a/README.md b/README.md
index 2c8a055..0b50d72 100644
--- a/README.md
+++ b/README.md
@@ -33,4 +33,4 @@ You can setup options in administration menu.
## Compatibility
-This version supports redmine 3.x.
+This version supports redmine 4.x.
diff --git a/app/controllers/reminder_configuration_controller.rb b/app/controllers/reminder_configuration_controller.rb
index ab289b0..235bbde 100644
--- a/app/controllers/reminder_configuration_controller.rb
+++ b/app/controllers/reminder_configuration_controller.rb
@@ -3,7 +3,7 @@ class ReminderConfigurationController < ApplicationController
layout 'admin'
- before_filter :require_admin
+ before_action :require_admin
def edit
@configuration = ReminderConfiguration.instance
@@ -23,7 +23,7 @@ def update
def permitted_conf_params
params.required(:reminder_configuration).permit(
:days, :issue_status_selector, :project_selector, :tracker_selector, :send_to_author,
- :send_to_assigned_to, :send_to_watcher, :send_to_custom_user,
+ :send_to_assigned_to, :use_due_day, :send_to_watcher, :send_to_custom_user,
{ issue_status_ids: [] },
{ project_ids: [] },
{ tracker_ids: [] }
diff --git a/app/models/reminder_all_mailer.rb b/app/models/reminder_all_mailer.rb
index 7572c49..f11d0ef 100644
--- a/app/models/reminder_all_mailer.rb
+++ b/app/models/reminder_all_mailer.rb
@@ -1,7 +1,7 @@
class ReminderAllMailer < Mailer
helper :reminder_all
- def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, days)
+ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, without_due_day, days)
recipients = user.mail
day_tag = [l(:mail_reminder_all_day1), l(:mail_reminder_all_day2),
l(:mail_reminder_all_day2), l(:mail_reminder_all_day2),
@@ -25,6 +25,7 @@ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user
@auth_issues = auth_issues
@watched_issues = watched_issues
@custom_user_issues = custom_user_issues
+ @without_due_day = without_due_day
@days = days
@issues_url = url_for(
controller: 'issues',
@@ -35,9 +36,9 @@ def reminder_all(user, assigned_issues, auth_issues, watched_issues, custom_user
mail to: recipients, subject: subject
end
- def self.deliver_reminder_all_if_any(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, days)
- issues_count = (assigned_issues + auth_issues + watched_issues + custom_user_issues).uniq.size
+ def self.deliver_reminder_all_if_any(user, assigned_issues, auth_issues, watched_issues, custom_user_issues, without_due_day, days)
+ issues_count = (assigned_issues + auth_issues + watched_issues + custom_user_issues + without_due_day).uniq.size
reminder_all(user, assigned_issues, auth_issues, watched_issues,
- custom_user_issues, days).deliver if issues_count > 0
+ custom_user_issues, without_due_day, days).deliver_later if issues_count > 0
end
end
diff --git a/app/models/reminder_configuration.rb b/app/models/reminder_configuration.rb
index 2665d62..72274c4 100644
--- a/app/models/reminder_configuration.rb
+++ b/app/models/reminder_configuration.rb
@@ -53,6 +53,7 @@ def set_default_values
self.send_to_assigned_to = true if self.send_to_assigned_to.nil?
self.send_to_watcher = true if self.send_to_watcher.nil?
self.send_to_custom_user ||= false
+ self.use_due_day ||= false
true
end
end
diff --git a/app/views/reminder_all_mailer/reminder_all.html.erb b/app/views/reminder_all_mailer/reminder_all.html.erb
index c27851b..6b66162 100644
--- a/app/views/reminder_all_mailer/reminder_all.html.erb
+++ b/app/views/reminder_all_mailer/reminder_all.html.erb
@@ -14,4 +14,8 @@
issues: @custom_user_issues,
message: l_mail_body_reminder_custom_user(@custom_user_issues.size, @days) } %>
+<%= render partial: 'issues', locals: {
+ issues: @without_due_day,
+ message: l(:mail_body_reminder_assigned_set, @without_due_day.size) } %>
+
<%= link_to l(:label_issue_view_all), @issues_url %>
diff --git a/app/views/reminder_all_mailer/reminder_all.text.erb b/app/views/reminder_all_mailer/reminder_all.text.erb
index c06f6d4..deb3e6b 100644
--- a/app/views/reminder_all_mailer/reminder_all.text.erb
+++ b/app/views/reminder_all_mailer/reminder_all.text.erb
@@ -14,4 +14,8 @@
issues: @custom_user_issues,
message: l_mail_body_reminder_custom_user(@custom_user_issues.size, @days) } %>
+<%= render partial: 'issues', locals: {
+ issues: @without_due_day,
+ message: l(:mail_body_reminder_assigned_set, @without_due_day.size) } %>
+
<%= @issues_url %>
diff --git a/app/views/reminder_configuration/edit.html.erb b/app/views/reminder_configuration/edit.html.erb
index 38524bd..88ef213 100644
--- a/app/views/reminder_configuration/edit.html.erb
+++ b/app/views/reminder_configuration/edit.html.erb
@@ -39,6 +39,10 @@
<%= f.check_box :send_to_author %>
<%= f.label :send_to_author, l(:field_author) %>
+
+
+ <%= f.check_box :use_due_day %>
+ <%= f.label :use_due_day, l(:field_use_due_day) %>
<%= f.check_box :send_to_assigned_to %>
diff --git a/assets/javascripts/reminder_configuration.js b/assets/javascripts/reminder_configuration.js
index cc90b99..c7eae00 100644
--- a/assets/javascripts/reminder_configuration.js
+++ b/assets/javascripts/reminder_configuration.js
@@ -1,13 +1,13 @@
var toggleExplicitList = function(selector, list, explicit_value) {
var fnToggleList = function() {
- if ($(selector).getValue() == explicit_value) {
+ if ($(selector).val() == explicit_value) {
$(list).show();
} else {
$(list).hide();
}
};
- $(selector).observe('change', fnToggleList);
+ $(selector).on('change', fnToggleList);
fnToggleList();
};
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fc063c2..1a53d18 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -17,6 +17,7 @@ en:
mail_body_reminder_assigned5: "%{count} issues that are assigned to you are due in the next %{days} %{day}:"
mail_body_reminder_watched5: "%{count} issues that are watched by you are due in the next %{days} %{day}:"
mail_body_reminder_custom_user5: "%{count} issues in which you are mentioned are due in the next %{days} %{day}:"
+ mail_body_reminder_assigned_set: "%{count} issues that are assigned to you which don't have end date set:"
label_reminder_options: "Reminder options"
label_criteria_task: "Criteria task"
@@ -37,3 +38,4 @@ en:
explicit: "tasks from selected trackers"
field_custom_user: "User from custom field"
+ field_use_due_day: "Send tasks which have end date only"
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
new file mode 100644
index 0000000..4d38a92
--- /dev/null
+++ b/config/locales/pl.yml
@@ -0,0 +1,39 @@
+pl:
+ mail_reminder_all_day1: "dnia"
+ mail_reminder_all_day2: "dni"
+ mail_reminder_all_day5: "dni"
+ mail_subject_reminder_all1: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}"
+ mail_body_reminder_auth1: "%{count} zadań do wykonania w ciągu %{days} %{day}, których jesteś autorem:"
+ mail_body_reminder_assigned1: "%{count} zadań do wykonania w ciągu %{days} %{day}, do których jesteś przypisany:"
+ mail_body_reminder_watched1: "%{count} zadań do wykonania w ciągu %{days} %{day}, których jesteś obserwatorem:"
+ mail_body_reminder_custom_user1: "%{count} zadań do wykonania w ciągu %{days} %{day}, w których o Tobie wspomniano:"
+ mail_subject_reminder_all2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}"
+ mail_body_reminder_auth2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś autorem:"
+ mail_body_reminder_assigned2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, do których jesteś przypisany:"
+ mail_body_reminder_watched2: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś obserwatorem:"
+ mail_body_reminder_custom_user2: "%{count} issues in which you are mentioned are due in the next %{days} %{day}:"
+ mail_subject_reminder_all5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}"
+ mail_body_reminder_auth5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś autorem:"
+ mail_body_reminder_assigned5: "%{count} issues that are assigned to you are due in the next %{days} %{day}:"
+ mail_body_reminder_watched5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, których jesteś obserwatorem:"
+ mail_body_reminder_custom_user5: "%{count} zadań do wykonania w ciągu następnych %{days} %{day}, w których o Tobie wspomniano:"
+
+ label_reminder_options: "Przypominacz - ustawienia"
+ label_criteria_task: "Kryteria zadania"
+ label_completion_date: "Data ukończenia"
+ label_tasks_due_in: "Zadania, które muszą być ukończonew ciągu następnych"
+ label_days: "Dni"
+ label_reminder_recipients: "Odbiorcy przypominacza"
+
+ redmine_reminder:
+ issue_statuses:
+ all_opened: "Wszystkie otwarte zadania"
+ explicit: "Zadania z wybranym statusem"
+ projects:
+ all: "Zadania ze wszystkich projektów"
+ explicit: "Zadania z wybranych projektów"
+ trackers:
+ all: "Zadania każdego typu"
+ explicit: "Wybrane typy zadań"
+
+ field_custom_user: "Użytkownik z pola niestandardowego"
diff --git a/db/migrate/20120911151845_create_reminder_configurations.rb b/db/migrate/20120911151845_create_reminder_configurations.rb
index cb523e4..1e579a8 100644
--- a/db/migrate/20120911151845_create_reminder_configurations.rb
+++ b/db/migrate/20120911151845_create_reminder_configurations.rb
@@ -1,4 +1,4 @@
-class CreateReminderConfigurations < ActiveRecord::Migration
+class CreateReminderConfigurations < ActiveRecord::Migration[5.1]
def self.up
create_table :reminder_configurations do |t|
t.column :days, :integer
diff --git a/db/migrate/20120911164322_create_reminder_projects.rb b/db/migrate/20120911164322_create_reminder_projects.rb
index 0f9b937..57816af 100644
--- a/db/migrate/20120911164322_create_reminder_projects.rb
+++ b/db/migrate/20120911164322_create_reminder_projects.rb
@@ -1,4 +1,4 @@
-class CreateReminderProjects < ActiveRecord::Migration
+class CreateReminderProjects < ActiveRecord::Migration[5.1]
def self.up
create_table :reminder_projects do |t|
t.column :reminder_configuration_id, :integer
diff --git a/db/migrate/20120911164358_create_reminder_issue_statuses.rb b/db/migrate/20120911164358_create_reminder_issue_statuses.rb
index ef7fdc2..8b613e3 100644
--- a/db/migrate/20120911164358_create_reminder_issue_statuses.rb
+++ b/db/migrate/20120911164358_create_reminder_issue_statuses.rb
@@ -1,4 +1,4 @@
-class CreateReminderIssueStatuses < ActiveRecord::Migration
+class CreateReminderIssueStatuses < ActiveRecord::Migration[5.1]
def self.up
create_table :reminder_issue_statuses do |t|
t.column :reminder_configuration_id, :integer
diff --git a/db/migrate/20120918093621_create_reminder_trackers.rb b/db/migrate/20120918093621_create_reminder_trackers.rb
index 14ef362..e07d1d2 100644
--- a/db/migrate/20120918093621_create_reminder_trackers.rb
+++ b/db/migrate/20120918093621_create_reminder_trackers.rb
@@ -1,4 +1,4 @@
-class CreateReminderTrackers < ActiveRecord::Migration
+class CreateReminderTrackers < ActiveRecord::Migration[5.1]
def self.up
create_table :reminder_trackers do |t|
t.column :reminder_configuration_id, :integer
diff --git a/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb b/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb
index 43915da..758678d 100644
--- a/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb
+++ b/db/migrate/20120918095158_add_tracker_selector_to_reminder_configurations.rb
@@ -1,4 +1,4 @@
-class AddTrackerSelectorToReminderConfigurations < ActiveRecord::Migration
+class AddTrackerSelectorToReminderConfigurations < ActiveRecord::Migration[5.1]
def self.up
unless column_exists? :reminder_configurations, :tracker_selector
add_column :reminder_configurations, :tracker_selector, :string
diff --git a/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb
new file mode 100644
index 0000000..c11c688
--- /dev/null
+++ b/db/migrate/20170624100352_add_use_due_day_to_reminder_configuration.rb
@@ -0,0 +1,5 @@
+class AddUseDueDayToReminderConfiguration < ActiveRecord::Migration[5.1]
+ def change
+ add_column :reminder_configurations, :use_due_day, :boolean, default: false
+ end
+end
diff --git a/init.rb b/init.rb
index e243884..e74ebf6 100644
--- a/init.rb
+++ b/init.rb
@@ -11,7 +11,7 @@
menu :admin_menu,
:reminder_options,
{ controller: 'reminder_configuration', action: 'edit' },
- html: { class: 'reminder_options_label' }
+ html: { class: 'icon reminder_options_label' }
end
require_dependency 'redmine_reminder/hooks'
diff --git a/lib/redmine_reminder/collector.rb b/lib/redmine_reminder/collector.rb
index 90ed49c..a1bd967 100644
--- a/lib/redmine_reminder/collector.rb
+++ b/lib/redmine_reminder/collector.rb
@@ -5,28 +5,41 @@ def initialize(options)
@options = options
end
+ def logger
+ Rails.logger
+ end
+
def collect_reminders
reminders = {}
- issues = issues_due_in_days
- issues.each do |issue|
+ issues = if options.use_due_day?
+ issues_due_in_days(true)
+ else
+ issues_due_in_days(false)
+ end
+ # logger.info issues.count()
+ issues.each do |issue|
if options.send_to_author?
reminders[issue.author] ||=
- RedmineReminder::Reminder.new(issue.author)
+ RedmineReminder::Reminder.new(issue.author)
reminders[issue.author][:author] << issue
end
- if options.send_to_assigned_to? && issue.assigned_to
+ if options.send_to_assigned_to? && issue.assigned_to && issue.due_date
reminders[issue.assigned_to] ||=
- RedmineReminder::Reminder.new(issue.assigned_to)
+ RedmineReminder::Reminder.new(issue.assigned_to)
reminders[issue.assigned_to][:assigned_to] << issue
+ #logger.info "v=#{issue}"
+ #logger.info "v.author=#{issue.author}"
+ #logger.info "v.assigned_to=#{issue.assigned_to}"
+ #logger.info "v.due_date=#{issue.due_date}"
end
if options.send_to_watcher?
issue.watchers.each do |watcher|
reminders[watcher.user] ||=
- RedmineReminder::Reminder.new(watcher.user)
+ RedmineReminder::Reminder.new(watcher.user)
reminders[watcher.user][:watcher] << issue
end
end
@@ -34,27 +47,52 @@ def collect_reminders
if options.send_to_custom_user?
issue_custom_users(issue).each do |custom_user|
reminders[custom_user] ||=
- RedmineReminder::Reminder.new(custom_user)
+ RedmineReminder::Reminder.new(custom_user)
reminders[custom_user][:custom_user] << issue
end
+ end
+
+ if !options.use_due_day? && issue.assigned_to && !issue.due_date
+ #logger.info "v=#{issue}"
+ #logger.info "v.author=#{issue.author}"
+ #logger.info "v.assigned_to=#{issue.assigned_to}"
+ #logger.info "v.due_date=#{issue.due_date}"
+ reminders[issue.assigned_to] ||=
+ RedmineReminder::Reminder.new(issue.assigned_to)
+ reminders[issue.assigned_to][:without_due_day] << issue
end
end
reminders.values.map &:uniq!
reminders.values || []
+
+ #reminders.values.each do |v|
+ # logger.info "v=#{v}"
+ # logger.info "v.user=#{v.user}"
+ #end
+
end
private
# Get issues due in X days
- def issues_due_in_days
+ def issues_due_in_days(use_due_day = true)
due_date = options.days.day.from_now.to_date
- sql_condition = ARCondition.new ["#{Issue.table_name}.due_date <= ?", due_date]
+ sql_condition = if use_due_day
+ ARCondition.new ["#{Issue.table_name}.due_date <= ?", due_date]
+ else
+ ARCondition.new ["#{Issue.table_name}.due_date <= ? OR #{Issue.table_name}.due_date IS NULL", due_date]
+ end
+
sql_condition << issue_statuses
sql_condition << projects
sql_condition << trackers
- Issue.joins(:status, :assigned_to, :author, :project, :watchers, :tracker).
- where(sql_condition.conditions).
- order("#{Issue.table_name}.due_date, #{Project.table_name}.name")
+ scope = Issue.includes(:status, :assigned_to, :author, :project, :watchers, :tracker)
+ if Redmine::VERSION::MAJOR>=3
+ scope = scope.references(:status, :assigned_to, :author, :project, :watchers, :tracker)
+ end
+
+ scope.where(sql_condition.conditions).
+ order("#{Project.table_name}.name, #{Issue.table_name}.due_date")
end
def issue_statuses
diff --git a/lib/tasks/reminder_all.rake b/lib/tasks/reminder_all.rake
index d5fe745..f5ebe69 100644
--- a/lib/tasks/reminder_all.rake
+++ b/lib/tasks/reminder_all.rake
@@ -30,16 +30,26 @@ namespace :redmine do
collector = RedmineReminder::Collector.new(options)
collector.collect_reminders.each do |r|
- next unless r.user.active?
+ users = if r.user.is_a?(User)
+ [r.user]
+ else
+ r.user.users
+ end
+ users = users.compact.select{|u| u.active?}
+ next unless users.blank?
ReminderAllMailer.with_synched_deliveries do
- ReminderAllMailer.deliver_reminder_all_if_any(
- r.user,
- r[:assigned_to],
- r[:author],
- r[:watcher],
- r[:custom_user],
- options.days
- )
+ users.each do |user|
+ ReminderAllMailer.deliver_reminder_all_if_any(
+ user,
+ r[:assigned_to],
+ r[:author],
+ r[:watcher],
+ r[:custom_user],
+ r[:without_due_day],
+ options.days
+ )
+ end
+
end
end
end