Book Image

Redmine Plugin Extension and Development

By : Alex Bevilacqua
Book Image

Redmine Plugin Extension and Development

By: Alex Bevilacqua

Overview of this book

Table of Contents (16 chapters)
Redmine Plugin Extension and Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Exposing plugin methods to the settings partial


One of the settings we have is a toggle for whether article summaries should be visible.

As this feature was added after the initial introduction of article summaries, it will be useful to administrators if they could gauge how many people are actually using this feature before they disable it.

First, we'll define a method in KnowledgebaseSettingsHelper, which is located at /path/to/redmine/plugins/redmine_knowlegebase/app/helpers/knowledgebase_settings_helper.rb.

module KnowledgebaseSettingsHelper
  def redmine_knowledgebase_count_article_summaries
    "#{KbArticle.count_article_summaries} of #{KbArticle.count} have summaries"
  end
end

For reference, the count_article_summaries method that is cited from the KbArticle model is as follows:

def self.count_article_summaries
  KbArticle.where("summary is not null and summary <> ''").count
end

We'll now update our plugin settings partial to include the summary count. Once this is done, if we try...