Initial commit
ci/woodpecker/manual/test_build Pipeline failed

This commit is contained in:
2026-06-07 17:56:08 +05:00
commit e436d0e8d8
77 changed files with 4533 additions and 0 deletions
@@ -0,0 +1,46 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
def self.settings() Setting.plugin_redmine_checklists.blank? ? {} : Setting.plugin_redmine_checklists end
def self.block_issue_closing?
settings['block_issue_closing'].to_i > 0
end
def self.issue_done_ratio?
settings['issue_done_ratio'].to_i > 0
end
end
REDMINE_CHECKLISTS_REQUIRED_FILES = [
'redmine_checklists/patches/compatibility/application_helper_patch',
'redmine_checklists/hooks/views_issues_hook',
'redmine_checklists/hooks/views_layouts_hook',
'redmine_checklists/hooks/controller_issues_hook',
'redmine_checklists/patches/issue_patch',
'redmine_checklists/patches/project_patch',
'redmine_checklists/patches/issues_controller_patch',
'redmine_checklists/patches/helper_for_checklists_patch',
'redmine_checklists/patches/issues_helper_patch',
'redmine_checklists/patches/compatibility/open_struct_patch',
]
base_url = File.dirname(__FILE__)
REDMINE_CHECKLISTS_REQUIRED_FILES.each { |file| require(base_url + '/' + file) }
@@ -0,0 +1,31 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ControllerIssuesHook < Redmine::Hook::ViewListener
def controller_issues_edit_after_save(context = {})
if (Setting.issue_done_ratio == 'issue_field') && RedmineChecklists.issue_done_ratio?
Checklist.recalc_issue_done_ratio(context[:issue].id)
end
end
end
end
end
@@ -0,0 +1,27 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ViewsIssuesHook < Redmine::Hook::ViewListener
render_on :view_issues_show_description_bottom, :partial => "issues/checklist"
render_on :view_issues_form_details_bottom, :partial => "issues/checklist_form"
end
end
end
@@ -0,0 +1,29 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ViewsLayoutsHook < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return javascript_include_tag(:checklists, :plugin => 'redmine_checklists') +
stylesheet_link_tag(:checklists, :plugin => 'redmine_checklists')
end
end
end
end
@@ -0,0 +1,36 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module ApplicationHelperPatch
def self.included(base) # :nodoc:
base.class_eval do
def stocked_reorder_link(object, name = nil, url = {}, method = :post)
Redmine::VERSION.to_s > '3.3' ? reorder_handle(object, :param => name) : reorder_links(name, url, method)
end
end
end
end
end
end
unless ApplicationHelper.included_modules.include?(RedmineChecklists::Patches::ApplicationHelperPatch)
ApplicationHelper.send(:include, RedmineChecklists::Patches::ApplicationHelperPatch)
end
@@ -0,0 +1,38 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require 'ostruct'
class OpenStruct2 < OpenStruct
undef id if defined?(id)
def to_h
json
end
def [](key)
json[key.to_s]
end
def json
return @json if @json
@json = JSON.parse(to_json)
@json = @json['table'] if @json.has_key?('table')
@json
end
end
@@ -0,0 +1,32 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module HelperForChecklistsPatch
def self.apply(controller)
controller.send(:helper, 'checklists')
end
end
end
end
[IssuesController].each do |controller|
RedmineChecklists::Patches::HelperForChecklistsPatch.apply(controller)
end
@@ -0,0 +1,79 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'issue'
module RedmineChecklists
module Patches
module IssuePatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
attr_accessor :old_checklists, :removed_checklist_ids, :checklists_from_params
attr_reader :copied_from
alias_method :after_create_from_copy_without_checklists, :after_create_from_copy
alias_method :after_create_from_copy, :after_create_from_copy_with_checklists
has_many :checklists, lambda { order("#{Checklist.table_name}.position") }, :class_name => 'Checklist', :dependent => :destroy, :inverse_of => :issue
accepts_nested_attributes_for :checklists, :allow_destroy => true, :reject_if => proc { |attrs| attrs['subject'].blank? }
validate :block_issue_closing_if_checklists_unclosed
safe_attributes 'checklists_attributes',
:if => lambda { |issue, user| (user.allowed_to?(:done_checklists, issue.project) || user.allowed_to?(:edit_checklists, issue.project)) }
end
end
module InstanceMethods
def copy_checklists
checklists_attributes = copied_from.checklists.map { |checklist| checklist.attributes.dup.except('id', 'issue_id').merge('issue_id' => id) }
checklists.create(checklists_attributes)
end
def after_create_from_copy_with_checklists
after_create_from_copy_without_checklists
copy_checklists if copy? && checklists.blank? && copied_from.checklists.present? && !checklists_from_params
end
def all_checklist_items_is_done?
(checklists - checklists.where(id: removed_checklist_ids)).reject(&:is_section).all?(&:is_done)
end
def need_to_block_issue_closing?
RedmineChecklists.block_issue_closing? &&
checklists.reject(&:is_section).any? &&
status.is_closed? &&
!all_checklist_items_is_done?
end
def block_issue_closing_if_checklists_unclosed
if need_to_block_issue_closing?
errors.add(:checklists, l(:label_checklists_must_be_completed))
end
end
end
end
end
end
unless Issue.included_modules.include?(RedmineChecklists::Patches::IssuePatch)
Issue.send(:include, RedmineChecklists::Patches::IssuePatch)
end
@@ -0,0 +1,38 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'query'
module RedmineChecklists
module Patches
module IssueQueryPatch
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
end
end
end
end
if (ActiveRecord::Base.connection.tables.include?('queries') rescue false) &&
IssueQuery.included_modules.exclude?(RedmineChecklists::Patches::IssueQueryPatch)
IssueQuery.send(:include, RedmineChecklists::Patches::IssueQueryPatch)
end
@@ -0,0 +1,87 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module IssuesControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :build_new_issue_from_params_without_checklist, :build_new_issue_from_params
alias_method :build_new_issue_from_params, :build_new_issue_from_params_with_checklist
before_action :save_before_state, :only => [:update]
end
end
module InstanceMethods
def build_new_issue_from_params_with_checklist
if params[:id].blank?
begin
if params[:copy_from].blank?
else
fill_checklist_attributes
end
rescue ActiveRecord::RecordNotFound
render_404
return
end
end
build_new_issue_from_params_without_checklist
@issue.checklists_from_params = true
end
def save_before_state
@issue.old_checklists = @issue.checklists.to_json
checklists_params = params.dig(:issue, :checklists_attributes) || {}
@issue.removed_checklist_ids =
if checklists_params.present?
checklists_params = checklists_params.to_unsafe_hash if checklists_params.respond_to?(:to_unsafe_hash)
checklists_params.map { |_k, v| v['id'].to_i if ['1', 'true'].include?(v['_destroy']) }.compact
else
[]
end
end
def fill_checklist_attributes
return unless params[:issue].blank?
@copy_from = Issue.visible.find(params[:copy_from])
add_checklists_to_params(@copy_from.checklists)
end
def add_checklists_to_params(checklists)
params[:issue].blank? ? params[:issue] = { :checklists_attributes => {} } : params[:issue][:checklists_attributes] = {}
checklists.each_with_index do |checklist_item, index|
params[:issue][:checklists_attributes][index.to_s] = {
is_done: checklist_item.is_done,
subject: checklist_item.subject,
position: checklist_item.position,
is_section: checklist_item.is_section
}
end
end
end
end
end
end
unless IssuesController.included_modules.include?(RedmineChecklists::Patches::IssuesControllerPatch)
IssuesController.send(:include, RedmineChecklists::Patches::IssuesControllerPatch)
end
@@ -0,0 +1,86 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module IssuesHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :details_to_strings_without_checklists, :details_to_strings
alias_method :details_to_strings, :details_to_strings_with_checklists
end
end
module InstanceMethods
def details_to_strings_with_checklists(details, no_html = false, options = {})
details_checklist, details_other = details.partition{ |x| x.prop_key == 'checklist' }
if @issue.nil? || !User.current.allowed_to?(:view_checklists, @issue.try(:project), global: @issue.present?)
return details_to_strings_without_checklists(details_other, no_html, options)
end
details_checklist.map do |detail|
result = []
diff = Hash.new([])
if Checklist.old_format?(detail)
result << "<b>#{l(:label_checklist_item)}</b> #{l(:label_checklist_changed_from)} #{detail.old_value} #{l(:label_checklist_changed_to)} #{detail.value}"
else
diff = JournalChecklistHistory.new(detail.old_value, detail.value).diff
end
checklist_item_label = lambda do |item|
item[:is_section] ? l(:label_checklist_section) : l(:label_checklist_item)
end
if diff[:done].any?
diff[:done].each do |item|
result << "<b>#{ERB::Util.h l(:label_checklist_item)}</b> <input type='checkbox' class='checklist-checkbox' #{item.is_done ? 'checked' : '' } disabled> <i>#{ERB::Util.h item[:subject]}</i> #{ERB::Util.h l(:label_checklist_done)}"
end
end
if diff[:undone].any?
diff[:undone].each do |item|
result << "<b>#{ERB::Util.h l(:label_checklist_item)}</b> <input type='checkbox' class='checklist-checkbox' #{item.is_done ? 'checked' : '' } disabled> <i>#{ERB::Util.h item[:subject]}</i> #{ERB::Util.h l(:label_checklist_undone)}"
end
end
result = result.join('</li><li>').html_safe
result = nil if result.blank?
if result && no_html
result = result.gsub /<\/li><li>/, "\n"
result = result.gsub /<input type='checkbox' class='checklist-checkbox'[^c^>]*checked[^>]*>/, '[x]'
result = result.gsub /<input type='checkbox' class='checklist-checkbox'[^c^>]*>/, '[ ]'
result = result.gsub /<[^>]*>/, ''
result = CGI.unescapeHTML(result)
end
result
end.compact + details_to_strings_without_checklists(details_other, no_html, options)
end
end
end
end
end
unless IssuesHelper.included_modules.include?(RedmineChecklists::Patches::IssuesHelperPatch)
IssuesHelper.send(:include, RedmineChecklists::Patches::IssuesHelperPatch)
end
@@ -0,0 +1,20 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,39 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2024 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'project'
module RedmineChecklists
module Patches
module ProjectPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
end
end
module InstanceMethods
end
end
end
end
unless Project.included_modules.include?(RedmineChecklists::Patches::ProjectPatch)
Project.send(:include, RedmineChecklists::Patches::ProjectPatch)
end