Actualizar plugin Questions a 1.0.2 light

This commit is contained in:
Manuel Cillero 2020-11-22 21:40:10 +01:00
parent b9e569d03f
commit b37d1305f1
64 changed files with 394 additions and 229 deletions

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -70,6 +70,7 @@ module Redmine
end
def save_attachments(attachments, author = User.current)
attachments = attachments.to_unsafe_hash if attachments.respond_to?(:to_unsafe_hash)
attachments = attachments.values if attachments.is_a?(Hash)
if attachments.is_a?(Array)
attachments.each do |attachment|

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -28,5 +28,3 @@ require_dependency 'redmine_questions/patches/auto_completes_controller_patch'
require_dependency 'redmine_questions/patches/comment_patch'
require_dependency 'acts_as_attachable_questions/init'
require 'redmine_questions/patches/compatibility/application_controller_patch' if Rails::VERSION::MAJOR < 4

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,37 +0,0 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions 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_questions 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_questions. If not, see <http://www.gnu.org/licenses/>.
module RedmineQuestions
module Patches
module ApplicationControllerPatch
def self.included(base) # :nodoc:
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
class << self
alias_method :before_action, :before_filter
end
end
end
end
end
end
unless ApplicationController.included_modules.include?(RedmineQuestions::Patches::ApplicationControllerPatch)
ApplicationController.send(:include, RedmineQuestions::Patches::ApplicationControllerPatch)
end

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify
@ -20,8 +20,15 @@
module RedmineQuestions
module Patches
module MailerPatch
module ClassMethods
def deliver_question_comment_added(comment)
question_comment_added(User.current, comment).deliver_later
end
end
module InstanceMethods
def question_comment_added(comment)
def question_comment_added(_user = User.current, comment)
question = comment.commented.is_a?(Question) ? comment.commented : comment.commented.question
@question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id)
project_identifier = question.project.try(:identifier)
@ -36,7 +43,7 @@ module RedmineQuestions
:subject => "[#{project_prefix}] RE: #{question.subject}"
end
def question_question_added(question)
def question_question_added(_user = Current.user, question)
@question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id)
project_identifier = question.project.try(:identifier)
redmine_headers 'Project' => project_identifier, 'Question-Id' => question.id
@ -51,9 +58,9 @@ module RedmineQuestions
:subject => "[#{project_prefix}] #{question.subject}"
end
def question_answer_added(answer)
def question_answer_added(_user = Current.user, answer)
question = answer.question
@question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id)
@question_url = url_for(controller: 'questions', action: 'show', id: question.id)
project_identifier = question.project.try(:identifier)
redmine_headers 'Project' => project_identifier, 'Question-Id' => question.id
message_id question
@ -66,13 +73,14 @@ module RedmineQuestions
@answer = answer
@question = question
project_prefix = [project_identifier, question.section_name, "q&a#{question.id}"].compact.join(' - ')
mail :to => recipients,
:cc => cc,
:subject => "[#{project_prefix}] - answ##{answer.id} - RE: #{question.subject}"
mail to: recipients,
cc: cc,
subject: "[#{project_prefix}] - answ##{answer.id} - RE: #{question.subject}"
end
end
def self.included(receiver)
receiver.send :extend, ClassMethods
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -1,7 +1,7 @@
# This file is a part of Redmine Q&A (redmine_questions) plugin,
# Q&A plugin for Redmine
#
# Copyright (C) 2011-2018 RedmineUP
# Copyright (C) 2011-2020 RedmineUP
# http://www.redmineup.com/
#
# redmine_questions is free software: you can redistribute it and/or modify

View file

@ -38,13 +38,13 @@ END_DESC
next
end
question_attrs = topic.attributes.slice('subject', 'content', 'author_id', 'locked').merge('project_id' => project.try(:id))
question_attrs = topic.attributes.slice('subject', 'content', 'author_id', 'locked')
migrated_question = section.questions.create(question_attrs)
migrated_question.attachments = topic.attachments.map { |attachment| attachment.copy }
topic.children.each do |reply|
if section.section_type == 'questions'
answer_attrs = reply.slice('subject', 'content', 'author_id', 'locked').merge('project_id' => project.try(:id))
answer_attrs = reply.slice('subject', 'content', 'author_id', 'locked')
migrated_answer = migrated_question.answers.create(answer_attrs)
migrated_answer.attachments = reply.attachments.map { |attachment| attachment.copy }
else