Loriowar / redmine_issues_tree

Provides a tree view of the Redmine issues list
GNU General Public License v3.0
115 stars 72 forks source link

Error if issues are requested as atom feed and the feed is refreshed #85

Closed micjahn closed 5 years ago

micjahn commented 5 years ago

Redmine 3.2.x, plugin from the 3.2 branch

If I fetch the issue list as an atom feed and I want to refresh the feed it doesn't work. I made a small hack to fix the issue but I'm not a ruby programmer. I think there are better solutions then mine. It also fixes some troubles with TurtleMine (a Tortoise Redmine Plugin) when grabbing the issue list as atom feed.

module RedmineIssuesTree::IssuesControllerPatch
  extend ActiveSupport::Concern

  included do
    alias_method_chain :index, :redmine_issues_tree
  end

  def index_with_redmine_issues_tree
    case params[:format]
      when 'csv', 'pdf', 'atom', 'xml', 'json'
      index_without_redmine_issues_tree
      else
      skip_issues_tree_redirect = params.delete(:skip_issues_tree_redirect)

      if params[:project_id].present?
        if Setting.plugin_redmine_issues_tree.with_indifferent_access[:default_redirect_to_tree_view] == 'true'
          # @note: add additional parameter into all links on issues#index looks not so good as parsing a referer
          # @reason: we must prevent redirect to the tree_view if we do some actions on a plain view
          if skip_issues_tree_redirect == 'true' || URI(request.referer).path == project_issues_path
            index_without_redmine_issues_tree
          else
            redirect_to tree_index_project_issues_trees_path(request.query_parameters)
          end
        else
          index_without_redmine_issues_tree
        end
      else
        if Setting.plugin_redmine_issues_tree.with_indifferent_access[:default_redirect_to_tree_view_without_project] == 'true'
          # @note: add additional parameter into all links on issues#index looks not so good as parsing a referer
          # @reason: we must prevent redirect to the tree_view if we do some actions on a plain view
          if skip_issues_tree_redirect == 'true' || URI(request.referer).path == issues_path
            index_without_redmine_issues_tree
          else
            redirect_to tree_index_issues_trees_path(request.query_parameters)
          end
        else
          index_without_redmine_issues_tree
        end
      end
    end
  end

  module ClassMethods
    # stub
  end
end
Loriowar commented 5 years ago

@micjahn, thanks for issue and patch. Implemented for 3.x and 4.x versions. Please, check it if possible.