微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当问题状态更改为特定注释时,如何在Redmine中设置自动添加注释

如何解决当问题状态更改为特定注释时,如何在Redmine中设置自动添加注释

我正在使用Redmine 3.4.6,当问题状态更改为特定问题时,我需要使其添加注释。我发现可以通过保存挂钩后编辑控制器问题来实现,但是我找不到如何编写控制器挂钩的好例子。我是Ruby和编码的初学者,所以我要求某人解释我必须做些什么才能使其工作。 Issue

我的代码

module RedmineAutocomments
  module Hooks
    class RedmineAutocommentsHook < Redmine::Hook::ViewListener
      def controller_issues_edit_after_save(context={})
        issue = context[:issue]
        trackers = ["Tracker1","Tracker2","Tracker3"]
        if trackers.include? @issue.tracker
          if @issue.status == "Ready for handout"
            @comment = Comment.new
            @comment = 'Some comment need to be added'
            @news.comments << @comment
          end
        end
      end
    end
  end
end

解决方法

一切都不是很困难:

module RedmineAutocomments
  module Hooks
    class RedmineAutocommentsHook < Redmine::Hook::ViewListener
      def controller_issues_edit_after_save(context={})
        @issue = context[:issue]
        case @issue.project.id
        when 9
          case @issue.tracker.id
          when 13,14,20
            case @issue.status.id
            when 26
              @issue.notes = MESSAGE
              @issue.save
            end
          end
        end
      end
    end
  end
end

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。