LoginSignup
1
1

More than 5 years have passed since last update.

Redmineのメール通知に表示されるフィールドをカスタマイズする

Posted at

ずーっと悩んでましたが、結局のところ「ソースを直接修正する」のがベストだという結論に達したので。

「[Redmineをインストールしたディレクトリ]/apps/Redmine/htdocs/app/helpers」ディレクトリ内の「issues_helper.rb」に記述されている「email_issue_attributes」関数を修正することで、メール通知の文面に表示されるフィールドをカスタマイズできます。

標準フィールドの表示項目を編集する

関数の2行目、(author status priority assigned_to category fixed_version)が、表示される標準フィールドを列挙した部分です。ここに必要なフィールドを追記し、不要なフィールドがあれば削除します。

カスタムフィールドを表示しないようにする

関数の後半、issue.visible_custom_field_values(user).each do |value|からendまでが、カスタムフィールドを順に表示させる部分です。カスタムフィールドの表示が不要なら、これをすべてコメントアウトしましょう。

こんな感じにしてみてはどうでしょう

def email_issue_attributes(issue, user, html)
  items = []
  %w(author status priority assigned_to category fixed_version start_date due_date).each do |attribute|
    unless issue.disabled_core_fields.include?(attribute+"_id")
      if html
        items << content_tag('strong', "#{l("field_#{attribute}")}: ") + (issue.send attribute)
      else
        items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
      end
    end
  end
# issue.visible_custom_field_values(user).each do |value|
#   if html
#     items << content_tag('strong', "#{value.custom_field.name}: ") + show_value(value, false)
#   else
#     items << "#{value.custom_field.name}: #{show_value(value, false)}"
#   end
# end
  items
end

こうすると、文面に開始日(start_date)と期日(due_date)が表示され、すべてのカスタムフィールドが表示されなくなります。文面スッキリ。

ほんとはいいプラグインがあればいいんですが。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1