Skip to content

Commit

Permalink
Merge pull request #52 from centosadmin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vladislav-yashin authored Feb 27, 2019
2 parents d74068e + 8d1db4e commit 3760bb6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.3.1

* Add copy status setting

# 0.3.0

* Improve errors handling
Expand Down
14 changes: 12 additions & 2 deletions app/models/recurring_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ def self.schedules(current_time = Time.now)
def copy_issue(associations = [])
return if issue.project.archived? || issue.project.closed?

settings = Setting.find_by(name: :plugin_redmine_recurring_tasks)&.value || {}

issue.deep_clone(include: associations, except: %i[parent_id root_id lft rgt created_on updated_on closed_on]) do |original, copy|
case original
when Issue
copy.init_journal(original.author)
new_author =
if Setting.plugin_redmine_recurring_tasks['use_anonymous_user']
if settings['use_anonymous_user']
User.anonymous
else
unless original.author.allowed_to?(:copy_issues, issue.project)
Expand All @@ -102,7 +104,15 @@ def copy_issue(associations = [])
copy.author_id = new_author.id
copy.tracker_id = original.tracker_id
copy.parent_issue_id = original.parent_id
copy.status = copy.new_statuses_allowed_to(original.author).first
copy.status_id =
case settings['copied_issue_status']
when nil
copy.new_statuses_allowed_to(original.author).sort_by(&:position).first&.id
when '0'
original.status_id
else
settings['copied_issue_status']
end
copy.attachments = original.attachments.map do |attachement|
attachement.copy(container: original)
end
Expand Down
7 changes: 7 additions & 0 deletions app/views/settings/_redmine_recurring_tasks.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
<p>
<%= button_tag l(:button_reset), type: :button, onClick: '$("#settings_associations option:selected").prop("selected", false);' %>
</p>

<p>
<%= label_tag 'settings[copied_issue_status]', l(:settings_copied_issue_status) %>
<%= select_tag 'settings[copied_issue_status]',
options_for_select([[l(:settings_copy_from_original), 0], *IssueStatus.sorted.map { |status| [status.name, status.id] }], @settings[:copied_issue_status]),
include_blank: true %>
</p>
<p>
<%= label_tag 'settings[use_anonymous_user]', l(:settings_use_anonymous_user) %>
<%= check_box_tag 'settings[use_anonymous_user]', 1, @settings[:use_anonymous_user] %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ en:
settings_associations: Issue associations to copy
settings_associations_warning: Warning! Incorrect settings may break plugin work. In case of problem try to turn off all options.
settings_use_anonymous_user: Use anonymous user while copying issues
settings_copied_issue_status: Copied issues status
settings_copy_from_original: Copy from original issue
2 changes: 2 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ru:
settings_associations: Связи для копирования
settings_associations_warning: Внимание! Некорректные настройки могут нарушить корректную работу плагина. При возникновении проблем попробуйте снять все опции.
settings_use_anonymous_user: Использовать анонимного пользователя для создания задач
settings_copied_issue_status: Статус задач-копий
settings_copy_from_original: Копировать из оригинала

activerecord:
attributes:
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
name 'Redmine Recurring Tasks'
author 'Southbridge'
description 'Plugin for creating scheduled tasks from template'
version '0.3.0'
version '0.3.1'
url 'https://github.com/centosadmin/redmine_recurring_tasks'
author_url 'https://github.com/centosadmin'

Expand Down

0 comments on commit 3760bb6

Please sign in to comment.