Merge branch 'rails6' into devel-1.0.8

This commit is contained in:
Karel.Picman 2022-03-17 07:59:39 +01:00
commit f9c887aa19
17 changed files with 112 additions and 74 deletions

View File

@ -22,9 +22,4 @@
source 'https://rubygems.org' do source 'https://rubygems.org' do
gem 'acts_as_list' gem 'acts_as_list'
gem 'activemodel-serializers-xml' gem 'activemodel-serializers-xml'
# Redmine extensions
unless %w(easyproject easy_gantt).any? { |plugin| Dir.exist?(File.expand_path("../../#{plugin}", __FILE__)) }
gem 'redmine_extensions', '~> 0.3.9'
end
end end

View File

@ -22,8 +22,6 @@
require_dependency File.dirname(__FILE__) + '/lib/redmine_custom_workflows.rb' require_dependency File.dirname(__FILE__) + '/lib/redmine_custom_workflows.rb'
ActiveSupport::Dependencies.autoload_paths << File.join(File.dirname(__FILE__), 'app')
def custom_workflows_init def custom_workflows_init
# Administration menu extension # Administration menu extension
Redmine::MenuManager.map :admin_menu do |menu| Redmine::MenuManager.map :admin_menu do |menu|

View File

@ -21,20 +21,20 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Hooks # Hooks
require 'redmine_custom_workflows/hooks/hooks' require File.dirname(__FILE__) + '/redmine_custom_workflows/hooks/views/base_view_hooks'
# Errors # Errors
require 'redmine_custom_workflows/errors/workflow_error' require File.dirname(__FILE__) + '/redmine_custom_workflows/errors/workflow_error'
# Patches # Patches
require 'redmine_custom_workflows/patches/attachment_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/attachment_patch'
require 'redmine_custom_workflows/patches/group_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/group_patch'
require 'redmine_custom_workflows/patches/issue_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_patch'
require 'redmine_custom_workflows/patches/issue_relation_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/issue_relation_patch'
require 'redmine_custom_workflows/patches/project_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/project_patch'
require 'redmine_custom_workflows/patches/projects_helper_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/projects_helper_patch'
require 'redmine_custom_workflows/patches/time_entry_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/time_entry_patch'
require 'redmine_custom_workflows/patches/user_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/user_patch'
require 'redmine_custom_workflows/patches/version_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/version_patch'
require 'redmine_custom_workflows/patches/wiki_content_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_content_patch'
require 'redmine_custom_workflows/patches/wiki_page_patch' require File.dirname(__FILE__) + '/redmine_custom_workflows/patches/wiki_page_patch'

View File

@ -20,11 +20,16 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WorkflowError < StandardError module RedmineCustomWorkflows
attr_accessor :error module Errors
def initialize(message) class WorkflowError < StandardError
@error = message attr_accessor :error
super message
def initialize(message)
@error = message
super message
end
end
end end
end end

View File

@ -21,14 +21,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module RedmineCustomWorkflows module RedmineCustomWorkflows
module Hooks
module Views
class Hooks < Redmine::Hook::ViewListener class BaseViewHooks < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name)
"\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows)
end
end
def view_layouts_base_html_head(context={})
return unless /^(CustomWorkflows|Projects)/.match?(context[:controller].class.name)
"\n".html_safe + stylesheet_link_tag('custom_workflows.css', plugin: :redmine_custom_workflows)
end end
end end
end end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module AttachmentPatch module AttachmentPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -60,6 +60,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'Attachment', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::AttachmentPatch' RedmineExtensions::PatchManager.register_model_patch 'Attachment', 'RedmineCustomWorkflows::Patches::AttachmentPatch'
else
Attachment.prepend RedmineCustomWorkflows::Patches::AttachmentPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module GroupPatch module GroupPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -74,6 +74,10 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'Group', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::GroupPatch' RedmineExtensions::PatchManager.register_model_patch 'Group',
'RedmineCustomWorkflows::Patches::GroupPatch'
else
Group.prepend RedmineCustomWorkflows::Patches::GroupPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module IssuePatch module IssuePatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -88,6 +88,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'Issue', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::IssuePatch' RedmineExtensions::PatchManager.register_model_patch 'Issue', 'RedmineCustomWorkflows::Patches::IssuePatch'
else
Issue.prepend RedmineCustomWorkflows::Patches::IssuePatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module IssueRelationPatch module IssueRelationPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -73,6 +73,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'IssueRelation', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::IssueRelationPatch' RedmineExtensions::PatchManager.register_model_patch 'IssueRelation', 'RedmineCustomWorkflows::Patches::IssueRelationPatch'
else
IssueRelation.prepend RedmineCustomWorkflows::Patches::IssueRelationPatch
end

View File

@ -51,5 +51,9 @@ module RedmineCustomWorkflows
end end
end end
RedmineExtensions::PatchManager.register_model_patch 'Mailer', # Apply the patch
'RedmineCustomWorkflows::Patches::MailerPatch' if Redmine::Plugin.installed?(:easy_extensions)
RedmineExtensions::PatchManager.register_model_patch 'Mailer', 'RedmineCustomWorkflows::Patches::MailerPatch'
else
Mailer.prepend RedmineCustomWorkflows::Patches::MailerPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module ProjectPatch module ProjectPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
has_and_belongs_to_many :custom_workflows has_and_belongs_to_many :custom_workflows
safe_attributes :custom_workflow_ids, if: safe_attributes :custom_workflow_ids, if:
@ -75,6 +75,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'Project', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::ProjectPatch' RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineCustomWorkflows::Patches::ProjectPatch'
else
Project.prepend RedmineCustomWorkflows::Patches::ProjectPatch
end

View File

@ -35,6 +35,7 @@ module RedmineCustomWorkflows
end end
end end
# Apply the patch
if Redmine::Plugin.installed?(:easy_extensions) if Redmine::Plugin.installed?(:easy_extensions)
RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper', RedmineExtensions::PatchManager.register_helper_patch 'ProjectsHelper',
'RedmineCustomWorkflows::Patches::ProjectsHelperPatch', prepend: true 'RedmineCustomWorkflows::Patches::ProjectsHelperPatch', prepend: true

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module TimeEntryPatch module TimeEntryPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -60,6 +60,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'TimeEntry', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::TimeEntryPatch' RedmineExtensions::PatchManager.register_model_patch 'TimeEntry', 'RedmineCustomWorkflows::Patches::TimeEntryPatch'
else
TimeEntry.prepend RedmineCustomWorkflows::Patches::TimeEntryPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module UserPatch module UserPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -60,6 +60,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'User', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::UserPatch' RedmineExtensions::PatchManager.register_model_patch 'User', 'RedmineCustomWorkflows::Patches::UserPatch'
else
User.prepend RedmineCustomWorkflows::Patches::UserPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module VersionPatch module VersionPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -60,6 +60,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'Version', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::VersionPatch' RedmineExtensions::PatchManager.register_model_patch 'Version', 'RedmineCustomWorkflows::Patches::VersionPatch'
else
Version.prepend RedmineCustomWorkflows::Patches::VersionPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module WikiContentPatch module WikiContentPatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
before_save :before_save_custom_workflows before_save :before_save_custom_workflows
after_save :after_save_custom_workflows after_save :after_save_custom_workflows
@ -60,6 +60,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'WikiContent', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::WikiContentPatch' RedmineExtensions::PatchManager.register_model_patch 'WikiContent', 'RedmineCustomWorkflows::Patches::WikiContentPatch'
else
WikiContent.prepend RedmineCustomWorkflows::Patches::WikiContentPatch
end

View File

@ -24,7 +24,7 @@ module RedmineCustomWorkflows
module Patches module Patches
module WikiPagePatch module WikiPagePatch
def self.included(base) def self.prepended(base)
base.class_eval do base.class_eval do
def self.attachments_callback(event, page, attachment) def self.attachments_callback(event, page, attachment)
page.instance_variable_set :@page, page page.instance_variable_set :@page, page
@ -43,6 +43,9 @@ module RedmineCustomWorkflows
end end
end end
# Apply patch # Apply the patch
RedmineExtensions::PatchManager.register_model_patch 'WikiPage', if Redmine::Plugin.installed?(:easy_extensions)
'RedmineCustomWorkflows::Patches::WikiPagePatch' RedmineExtensions::PatchManager.register_model_patch 'WikiPage', 'RedmineCustomWorkflows::Patches::WikiPagePatch'
else
WikiPage.prepend RedmineCustomWorkflows::Patches::WikiPagePatch
end