ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index

git-svn-id: http://redmine.rubyforge.org/svn/trunk@887 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/351/head
Jean-Philippe Lang 17 years ago
parent 26a1ae4808
commit 8509cf80f0
  1. 95
      app/controllers/issues_controller.rb
  2. 142
      app/controllers/projects_controller.rb
  3. 4
      app/controllers/queries_controller.rb
  4. 52
      app/helpers/issues_helper.rb
  5. 4
      app/models/journal.rb
  6. 4
      app/views/issues/_sidebar.rhtml
  7. 30
      app/views/issues/changes.rxml
  8. 2
      app/views/issues/context_menu.rhtml
  9. 97
      app/views/issues/index.rfpdf
  10. 79
      app/views/issues/index.rhtml
  11. 72
      app/views/projects/list_issues.rhtml
  12. 4
      app/views/projects/roadmap.rhtml
  13. 4
      app/views/projects/show.rhtml
  14. 2
      app/views/queries/index.rhtml
  15. 10
      app/views/reports/_details.rhtml
  16. 8
      app/views/reports/_simple.rhtml
  17. 5
      config/environment.rb
  18. 1
      config/routes.rb
  19. 6
      lib/redmine.rb
  20. 86
      test/functional/issues_controller_test.rb
  21. 29
      test/functional/projects_controller_test.rb
  22. 2
      test/integration/issues_test.rb

@ -16,9 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssuesController < ApplicationController
layout 'base', :except => :export_pdf
before_filter :find_project, :authorize, :except => [:index, :preview]
accept_key_auth :index
layout 'base'
before_filter :find_project, :authorize, :except => [:index, :changes, :preview]
before_filter :find_optional_project, :only => [:index, :changes]
accept_key_auth :index, :changes
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
@ -37,37 +38,54 @@ class IssuesController < ApplicationController
helper :queries
helper :sort
include SortHelper
include IssuesHelper
def index
sort_init "#{Issue.table_name}.id", "desc"
sort_update
retrieve_query
if @query.valid?
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
@issue_pages = Paginator.new self, @issue_count, 25, params['page']
limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : 25
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
@issue_pages = Paginator.new self, @issue_count, limit, params['page']
@issues = Issue.find :all, :order => sort_clause,
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category ],
:conditions => @query.statement,
:limit => @issue_pages.items_per_page,
:offset => @issue_pages.current.offset
:limit => limit,
:offset => @issue_pages.current.offset
respond_to do |format|
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
format.pdf { send_data(render(:template => 'issues/index.rfpdf', :layout => false), :type => 'application/pdf', :filename => 'export.pdf') }
end
else
# Send html if the query is not valid
render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
end
respond_to do |format|
format.html { render :layout => false if request.xhr? }
format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
end
def changes
sort_init "#{Issue.table_name}.id", "desc"
sort_update
retrieve_query
if @query.valid?
@changes = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
:conditions => @query.statement,
:limit => 25,
:order => "#{Journal.table_name}.created_on DESC"
end
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
render :layout => false, :content_type => 'application/atom+xml'
end
def show
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
if params[:format]=='pdf'
@options_for_rfpdf ||= {}
@options_for_rfpdf[:file_name] = "#{@project.identifier}-#{@issue.id}.pdf"
render :template => 'issues/show.rfpdf', :layout => false
else
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
render :template => 'issues/show.rhtml'
@status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user
respond_to do |format|
format.html { render :template => 'issues/show.rhtml' }
format.pdf { send_data(render(:template => 'issues/show.rfpdf', :layout => false), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
end
end
@ -152,7 +170,7 @@ class IssuesController < ApplicationController
def destroy
@issue.destroy
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project
redirect_to :action => 'index', :project_id => @project
end
def destroy_attachment
@ -195,23 +213,38 @@ private
render_404
end
def find_optional_project
return true unless params[:project_id]
@project = Project.find(params[:project_id])
authorize
rescue ActiveRecord::RecordNotFound
render_404
end
# Retrieve query from session or build a new query
def retrieve_query
if params[:set_filter] or !session[:query] or session[:query].project_id
# Give it a name, required to be valid
@query = Query.new(:name => "_", :executed_by => logged_in_user)
if params[:fields] and params[:fields].is_a? Array
params[:fields].each do |field|
@query.add_filter(field, params[:operators][field], params[:values][field])
if params[:query_id]
@query = Query.find(params[:query_id], :conditions => {:project_id => (@project ? @project.id : nil)})
@query.executed_by = logged_in_user
session[:query] = @query
else
if params[:set_filter] or !session[:query] or session[:query].project != @project
# Give it a name, required to be valid
@query = Query.new(:name => "_", :executed_by => logged_in_user)
@query.project = @project
if params[:fields] and params[:fields].is_a? Array
params[:fields].each do |field|
@query.add_filter(field, params[:operators][field], params[:values][field])
end
else
@query.available_filters.keys.each do |field|
@query.add_short_filter(field, params[field]) if params[field]
end
end
session[:query] = @query
else
@query.available_filters.keys.each do |field|
@query.add_short_filter(field, params[field]) if params[field]
end
@query = session[:query]
end
session[:query] = @query
else
@query = session[:query]
end
end
end

@ -15,8 +15,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'csv'
class ProjectsController < ApplicationController
layout 'base'
before_filter :find_project, :except => [ :index, :list, :add ]
@ -238,118 +236,13 @@ class ProjectsController < ApplicationController
end
flash[:notice] = l(:notice_successful_create)
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
redirect_to :action => 'list_issues', :id => @project
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
return
end
end
@priorities = Enumeration::get_values('IPRI')
end
# Show filtered/sorted issues list of @project
def list_issues
sort_init "#{Issue.table_name}.id", "desc"
sort_update
retrieve_query
@results_per_page_options = [ 15, 25, 50, 100 ]
if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
@results_per_page = params[:per_page].to_i
session[:results_per_page] = @results_per_page
else
@results_per_page = session[:results_per_page] || 25
end
if @query.valid?
@issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
@issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
@issues = Issue.find :all, :order => sort_clause,
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category ],
:conditions => @query.statement,
:limit => @issue_pages.items_per_page,
:offset => @issue_pages.current.offset
end
render :layout => false if request.xhr?
end
# Export filtered/sorted issues list to CSV
def export_issues_csv
sort_init "#{Issue.table_name}.id", "desc"
sort_update
retrieve_query
render :action => 'list_issues' and return unless @query.valid?
@issues = Issue.find :all, :order => sort_clause,
:include => [ :assigned_to, :author, :status, :tracker, :priority, :project, {:custom_values => :custom_field} ],
:conditions => @query.statement,
:limit => Setting.issues_export_limit.to_i
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
export = StringIO.new
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
# csv header fields
headers = [ "#", l(:field_status),
l(:field_project),
l(:field_tracker),
l(:field_priority),
l(:field_subject),
l(:field_assigned_to),
l(:field_author),
l(:field_start_date),
l(:field_due_date),
l(:field_done_ratio),
l(:field_created_on),
l(:field_updated_on)
]
for custom_field in @project.all_custom_fields
headers << custom_field.name
end
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
# csv lines
@issues.each do |issue|
fields = [issue.id, issue.status.name,
issue.project.name,
issue.tracker.name,
issue.priority.name,
issue.subject,
(issue.assigned_to ? issue.assigned_to.name : ""),
issue.author.name,
issue.start_date ? l_date(issue.start_date) : nil,
issue.due_date ? l_date(issue.due_date) : nil,
issue.done_ratio,
l_datetime(issue.created_on),
l_datetime(issue.updated_on)
]
for custom_field in @project.all_custom_fields
fields << (show_value issue.custom_value_for(custom_field))
end
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
end
end
export.rewind
send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
end
# Export filtered/sorted issues to PDF
def export_issues_pdf
sort_init "#{Issue.table_name}.id", "desc"
sort_update
retrieve_query
render :action => 'list_issues' and return unless @query.valid?
@issues = Issue.find :all, :order => sort_clause,
:include => [ :author, :status, :tracker, :priority, :project ],
:conditions => @query.statement,
:limit => Setting.issues_export_limit.to_i
@options_for_rfpdf ||= {}
@options_for_rfpdf[:file_name] = "export.pdf"
render :layout => false
end
# Bulk edit issues
def bulk_edit_issues
if request.post?
@ -383,7 +276,7 @@ class ProjectsController < ApplicationController
else
flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #'))
end
redirect_to :action => 'list_issues', :id => @project
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
return
end
if current_role && User.current.allowed_to?(:change_issue_status, @project)
@ -399,7 +292,7 @@ class ProjectsController < ApplicationController
def move_issues
@issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
redirect_to :action => 'list_issues', :id => @project and return unless @issues
redirect_to :controller => 'issues', :action => 'index', :project_id => @project and return unless @issues
@projects = []
# find projects to which the user is allowed to move the issue
User.current.memberships.each {|m| @projects << m.project if m.role.allowed_to?(:controller => 'projects', :action => 'move_issues')}
@ -424,7 +317,7 @@ class ProjectsController < ApplicationController
i.save
end
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'list_issues', :id => @project
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
end
end
@ -659,31 +552,4 @@ private
@selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
end
end
# Retrieve query from session or build a new query
def retrieve_query
if params[:query_id]
@query = @project.queries.find(params[:query_id])
@query.executed_by = logged_in_user
session[:query] = @query
else
if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
# Give it a name, required to be valid
@query = Query.new(:name => "_", :executed_by => logged_in_user)
@query.project = @project
if params[:fields] and params[:fields].is_a? Array
params[:fields].each do |field|
@query.add_filter(field, params[:operators][field], params[:values][field])
end
else
@query.available_filters.keys.each do |field|
@query.add_short_filter(field, params[field]) if params[field]
end
end
session[:query] = @query
else
@query = session[:query]
end
end
end
end

@ -39,7 +39,7 @@ class QueriesController < ApplicationController
if request.post? && params[:confirm] && @query.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query
return
end
render :layout => false if request.xhr?
@ -57,7 +57,7 @@ class QueriesController < ApplicationController
if @query.save
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query
redirect_to :controller => 'issues', :action => 'index', :project_id => @project, :query_id => @query
end
end
end

@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'csv'
module IssuesHelper
def render_issue_tooltip(issue)
@ -101,4 +103,54 @@ module IssuesHelper
end
end
end
def issues_to_csv(issues, project = nil)
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
export = StringIO.new
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
# csv header fields
headers = [ "#",
l(:field_status),
l(:field_project),
l(:field_tracker),
l(:field_priority),
l(:field_subject),
l(:field_assigned_to),
l(:field_author),
l(:field_start_date),
l(:field_due_date),
l(:field_done_ratio),
l(:field_created_on),
l(:field_updated_on)
]
# only export custom fields if project is given
for custom_field in project.all_custom_fields
headers << custom_field.name
end if project
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
# csv lines
issues.each do |issue|
fields = [issue.id,
issue.status.name,
issue.project.name,
issue.tracker.name,
issue.priority.name,
issue.subject,
(issue.assigned_to ? issue.assigned_to.name : ""),
issue.author.name,
issue.start_date ? l_date(issue.start_date) : nil,
issue.due_date ? l_date(issue.due_date) : nil,
issue.done_ratio,
l_datetime(issue.created_on),
l_datetime(issue.updated_on)
]
for custom_field in project.all_custom_fields
fields << (show_value issue.custom_value_for(custom_field))
end if project
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
end
end
export.rewind
export
end
end

@ -29,6 +29,10 @@ class Journal < ActiveRecord::Base
:project_key => "#{Issue.table_name}.project_id",
:date_column => "#{Issue.table_name}.created_on"
acts_as_event :title => Proc.new {|o| "#{o.issue.tracker.name} ##{o.issue.id}: #{o.issue.subject}"},
:description => :notes,
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id}}
def save
# Do not save an empty journal
(details.empty? && notes.blank?) ? false : super

@ -4,7 +4,7 @@
<% end %>
<h3><%= l(:label_issue_plural) %></h3>
<%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %><br />
<%= link_to l(:label_issue_view_all), { :set_filter => 1 } %><br />
<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %><br />
<%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %>
@ -14,5 +14,5 @@
:order => "name ASC",
:conditions => ["is_public = ? or user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
queries.each do |query| %>
<%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %><br />
<%= link_to query.name, :controller => 'issues', :action => 'index', :project_id => @project, :query_id => query %><br />
<% end %>

@ -0,0 +1,30 @@
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.title @title
xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'history', :format => 'atom', :only_path => false)
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
xml.id url_for(:controller => 'welcome', :only_path => false)
xml.updated((@changes.first ? @changes.first.event_datetime : Time.now).xmlschema)
xml.author { xml.name "#{Setting.app_title}" }
@changes.each do |change|
issue = change.issue
xml.entry do
xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
xml.link "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
xml.id url_for(:controller => 'issues' , :action => 'show', :id => issue, :journal_id => change, :only_path => false)
xml.updated change.created_on.xmlschema
xml.author do
xml.name change.user.name
xml.email(change.user.mail)
end
xml.content "type" => "html" do
xml.text! '<ul>'
change.details.each do |detail|
xml.text! '<li>' + show_detail(detail, false) + '</li>'
end
xml.text! '</ul>'
xml.text! textilizable(change.notes) unless change.notes.blank?
end
end
end
end

@ -1,4 +1,4 @@
<% back_to = url_for(:controller => 'projects', :action => 'list_issues', :id => @project) %>
<% back_to = url_for(:controller => 'issues', :action => 'index', :project_id => @project) %>
<ul>
<li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue},
:class => 'icon-edit', :disabled => !@can[:edit] %></li>

@ -1,49 +1,50 @@
<% pdf=IfpdfHelper::IFPDF.new(current_language)
pdf.SetTitle("#{@project.name} - #{l(:label_issue_plural)}")
pdf.AliasNbPages
pdf.footer_date = format_date(Date.today)
pdf.AddPage("L")
row_height = 7
#
# title
#
pdf.SetFontStyle('B',11)
pdf.Cell(190,10, "#{@project.name} - #{l(:label_issue_plural)}")
pdf.Ln
#
# headers
#
pdf.SetFontStyle('B',10)
pdf.SetFillColor(230, 230, 230)
pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_status), 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_priority), 0, 0, 'L', 1)
pdf.Cell(40, row_height, l(:field_author), 0, 0, 'L', 1)
pdf.Cell(25, row_height, l(:field_updated_on), 0, 0, 'L', 1)
pdf.Cell(0, row_height, l(:field_subject), 0, 0, 'L', 1)
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.Ln
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.SetY(pdf.GetY() + 1)
#
# rows
#
pdf.SetFontStyle('',9)
pdf.SetFillColor(255, 255, 255)
@issues.each do |issue|
pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.tracker.name, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.status.name, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.priority.name, 0, 0, 'L', 1)
pdf.Cell(40, row_height, issue.author.name, 0, 0, 'L', 1)
pdf.Cell(25, row_height, format_date(issue.updated_on), 0, 0, 'L', 1)
pdf.MultiCell(0, row_height, (@project == issue.project ? issue.subject : "#{issue.project.name} - #{issue.subject}"))
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.SetY(pdf.GetY() + 1)
end
%>
<% pdf=IfpdfHelper::IFPDF.new(current_language)
title = @project ? "#{@project.name} - #{l(:label_issue_plural)}" : "#{l(:label_issue_plural)}"
pdf.SetTitle(title)
pdf.AliasNbPages
pdf.footer_date = format_date(Date.today)
pdf.AddPage("L")
row_height = 7
#
# title
#
pdf.SetFontStyle('B',11)
pdf.Cell(190,10, title)
pdf.Ln
#
# headers
#
pdf.SetFontStyle('B',10)
pdf.SetFillColor(230, 230, 230)
pdf.Cell(15, row_height, "#", 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_tracker), 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_status), 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_priority), 0, 0, 'L', 1)
pdf.Cell(40, row_height, l(:field_assigned_to), 0, 0, 'L', 1)
pdf.Cell(25, row_height, l(:field_updated_on), 0, 0, 'L', 1)
pdf.Cell(0, row_height, l(:field_subject), 0, 0, 'L', 1)
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.Ln
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.SetY(pdf.GetY() + 1)
#
# rows
#
pdf.SetFontStyle('',9)
pdf.SetFillColor(255, 255, 255)
@issues.each do |issue|
pdf.Cell(15, row_height, issue.id.to_s, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.tracker.name, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.status.name, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.priority.name, 0, 0, 'L', 1)
pdf.Cell(40, row_height, issue.assigned_to ? issue.assigned_to.name : '', 0, 0, 'L', 1)
pdf.Cell(25, row_height, format_date(issue.updated_on), 0, 0, 'L', 1)
pdf.MultiCell(0, row_height, (@project == issue.project ? issue.subject : "#{issue.project.name} - #{issue.subject}"))
pdf.Line(10, pdf.GetY, 287, pdf.GetY)
pdf.SetY(pdf.GetY() + 1)
end
%>
<%= pdf.Output %>

@ -1,35 +1,72 @@
<h2><%=l(:label_issue_plural)%></h2>
<% if @query.new_record? %>
<h2><%=l(:label_issue_plural)%></h2>
<% set_html_title l(:label_issue_plural) %>
<% form_tag({}, :id => 'query_form') do %>
<%= render :partial => 'queries/filters', :locals => {:query => @query} %>
<% form_tag({ :controller => 'queries', :action => 'new', :project_id => @project }, :id => 'query_form') do %>
<%= render :partial => 'queries/filters', :locals => {:query => @query} %>
<div class="contextual">
<%= link_to_remote l(:button_apply),
{ :url => { :set_filter => 1 },
:update => "content",
:with => "Form.serialize('query_form')"
}, :class => 'icon icon-edit' %>
<%= link_to_remote l(:button_clear),
{ :url => { :set_filter => 1 },
:update => "content",
}, :class => 'icon icon-reload' %>
<% if current_role && current_role.allowed_to?(:save_queries) %>
<%= link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save' %>
<% end %>
</div>
<br />
&nbsp;
<% end %>
<% else %>
<div class="contextual">
<% if @query.editable_by?(User.current) %>
<%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %>
<%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
<% end %>
</div>
<h2><%= @query.name %></h2>
<div id="query_form"></div>
<% set_html_title @query.name %>
<% end %>
<div class="contextual">
<%= link_to_remote l(:button_apply),
{ :url => { :set_filter => 1 },
:update => "content",
:with => "Form.serialize('query_form')"
}, :class => 'icon icon-edit' %>
<%= link_to_remote l(:button_clear),
{ :url => { :set_filter => 1 },
:update => "content",
}, :class => 'icon icon-reload' %>
</div>
<br />&nbsp;
<%= error_messages_for 'query' %>
<% if @query.valid? %>
<% if @issues.empty? %>
<p><i><%= l(:label_no_data) %></i></p>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
&nbsp;
<% form_tag({:controller => 'projects', :action => 'bulk_edit_issues', :id => @project}, :id => 'issues_form', :onsubmit => "if (!checkBulkEdit(this)) {alert('#{l(:notice_no_issue_selected)}'); return false;}" ) do %>
<%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
<div class="contextual">
<%= l(:label_export_to) %>
<%= link_to 'CSV', {:format => 'csv'}, :class => 'icon icon-csv' %>,
<%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %>
</div>
<p><%= pagination_links_full @issue_pages %>
[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]</p>
<% end %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<%= render :partial => 'issues/sidebar' %>
<% end if @project%>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
<%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural)) %>
<%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %>
<%= javascript_include_tag 'calendar/calendar' %>
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
<%= javascript_include_tag 'calendar/calendar-setup' %>
<%= stylesheet_link_tag 'calendar' %>
<%= javascript_include_tag 'context_menu' %>
<%= stylesheet_link_tag 'context_menu' %>
<% end %>
<div id="context-menu" style="display: none;"></div>
<%= javascript_tag 'new ContextMenu({})' %>

@ -1,72 +0,0 @@
<% if @query.new_record? %>
<h2><%=l(:label_issue_plural)%></h2>
<% set_html_title l(:label_issue_plural) %>
<% form_tag({ :controller => 'queries', :action => 'new', :project_id => @project }, :id => 'query_form') do %>
<%= render :partial => 'queries/filters', :locals => {:query => @query} %>
<div class="contextual">
<%= link_to_remote l(:button_apply),
{ :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 },
:update => "content",
:with => "Form.serialize('query_form')"
}, :class => 'icon icon-edit' %>
<%= link_to_remote l(:button_clear),
{ :url => {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1},
:update => "content",
}, :class => 'icon icon-reload' %>
<% if current_role.allowed_to?(:save_queries) %>
<%= link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save' %>
<% end %>
</div>
<br />
&nbsp;
<% end %>
<% else %>
<div class="contextual">
<% if @query.editable_by?(User.current) %>
<%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %>
<%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
<% end %>
</div>
<h2><%= @query.name %></h2>
<div id="query_form"></div>
<% set_html_title @query.name %>
<% end %>
<%= error_messages_for 'query' %>
<% if @query.valid? %>
<% if @issues.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<% form_tag({:controller => 'projects', :action => 'bulk_edit_issues', :id => @project}, :id => 'issues_form', :onsubmit => "if (!checkBulkEdit(this)) {alert('#{l(:notice_no_issue_selected)}'); return false;}" ) do %>
<%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
<div class="contextual">
<%= l(:label_export_to) %>
<%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon icon-csv' %>,
<%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'icon icon-pdf' %>
</div>
<p>
<%= pagination_links_full @issue_pages %>
[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]
</p>
<% end %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<%= render :partial => 'issues/sidebar' %>
<% end %>
<% content_for :header_tags do %>
<%= javascript_include_tag 'calendar/calendar' %>
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
<%= javascript_include_tag 'calendar/calendar-setup' %>
<%= stylesheet_link_tag 'calendar' %>
<%= javascript_include_tag 'context_menu' %>
<%= stylesheet_link_tag 'context_menu' %>
<% end %>
<div id="context-menu" style="display: none;"></div>
<%= javascript_tag 'new ContextMenu({})' %>

@ -34,8 +34,8 @@
<% end %>
</tr>
</table>
<em><%= link_to(complete, :controller => 'projects', :action => 'list_issues', :id => @project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_closed_issues, complete) %> (<%= percentComplete %>%) &#160;
<%= link_to((total - complete), :controller => 'projects', :action => 'list_issues', :id => @project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_open_issues, total - complete)%> (<%= percentIncomplete %>%)</em>
<em><%= link_to(complete, :controller => 'issues', :action => 'index', :project_id => @project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_closed_issues, complete) %> (<%= percentComplete %>%) &#160;
<%= link_to((total - complete), :controller => 'issues', :action => 'index', :project_id => @project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_open_issues, total - complete)%> (<%= percentIncomplete %>%)</em>
<br />
<br />
<%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>

@ -22,14 +22,14 @@
<h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3>
<ul>
<% for tracker in @trackers %>
<li><%= link_to tracker.name, :controller => 'projects', :action => 'list_issues', :id => @project,
<li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project,
:set_filter => 1,
"tracker_id" => tracker.id %>:
<%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %>
<%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li>
<% end %>
</ul>
<p><%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %></p>
<p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p>
</div>
<% end %>
</div>

@ -11,7 +11,7 @@
<% @queries.each do |query| %>
<tr class="<%= cycle('odd', 'even') %>">
<td>
<%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %>
<%= link_to query.name, :controller => 'issues', :action => 'index', :project_id => @project, :query_id => query %>
</td>
<td align="right">
<small>

@ -15,28 +15,28 @@
<tbody>
<% for row in rows %>
<tr class="<%= cycle("odd", "even") %>">
<td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
<td><%= link_to row.name, :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id %></td>
<% for status in @statuses %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "status_id" => status.id },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"status_id" => status.id,
"#{field_name}" => row.id %></td>
<% end %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "*" %></td>

@ -11,21 +11,21 @@
<tbody>
<% for row in rows %>
<tr class="<%= cycle("odd", "even") %>">
<td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
<td><%= link_to row.name, :controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id },
:controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:controller => 'issues', :action => 'index', :project_id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1,
"#{field_name}" => row.id,
"status_id" => "*" %></td>

@ -77,7 +77,10 @@ ActiveRecord::Errors.default_error_messages = {
}
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
Mime::Type.register 'text/csv', :csv
Mime::Type.register 'application/pdf', :pdf
GLoc.set_config :default_language => :en
GLoc.clear_strings
GLoc.set_kcode

@ -14,6 +14,7 @@ ActionController::Routing::Routes.draw do |map|
#map.connect ':controller/:action/:id/:sort_key/:sort_order'
map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'

@ -25,8 +25,8 @@ Redmine::AccessControl.map do |map|
# Issue categories
map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member
# Issues
map.permission :view_issues, {:projects => [:list_issues, :export_issues_csv, :export_issues_pdf, :changelog, :roadmap],
:issues => [:show, :context_menu],
map.permission :view_issues, {:projects => [:changelog, :roadmap],
:issues => [:index, :changes, :show, :context_menu],
:queries => :index,
:reports => :issue_report}, :public => true
map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin
@ -92,7 +92,7 @@ Redmine::MenuManager.map :project_menu do |menu|
menu.push :label_overview, :controller => 'projects', :action => 'show'
menu.push :label_activity, :controller => 'projects', :action => 'activity'
menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap'
menu.push :label_issue_plural, :controller => 'projects', :action => 'list_issues'
menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id
menu.push :label_news_plural, :controller => 'projects', :action => 'list_news'
menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents'
menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }

@ -0,0 +1,86 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.dirname(__FILE__) + '/../test_helper'
require 'issues_controller'
# Re-raise errors caught by the controller.
class IssuesController; def rescue_action(e) raise e end; end
class IssuesControllerTest < Test::Unit::TestCase
fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations
def setup
@controller = IssuesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
def test_index
get :index
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
assert_nil assigns(:project)
end
def test_index_with_project
get :index, :project_id => 1
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
end
def test_index_with_project_and_filter
get :index, :project_id => 1, :set_filter => 1
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
end
def test_index_csv_with_project
get :index, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
get :index, :project_id => 1, :format => 'csv'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'text/csv', @response.content_type
end
def test_index_pdf
get :index, :format => 'pdf'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'application/pdf', @response.content_type
get :index, :project_id => 1, :format => 'pdf'
assert_response :success
assert_not_nil assigns(:issues)
assert_equal 'application/pdf', @response.content_type
end
def test_changes
get :changes, :project_id => 1
assert_response :success
assert_not_nil assigns(:changes)
assert_equal 'application/atom+xml', @response.content_type
end
end

@ -55,33 +55,6 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_response :success
assert_template 'list_documents'
assert_not_nil assigns(:grouped)
end
def test_list_issues
get :list_issues, :id => 1
assert_response :success
assert_template 'list_issues'
assert_not_nil assigns(:issues)
end
def test_list_issues_with_filter
get :list_issues, :id => 1, :set_filter => 1
assert_response :success
assert_template 'list_issues'
assert_not_nil assigns(:issues)
end
def test_list_issues_reset_filter
post :list_issues, :id => 1
assert_response :success
assert_template 'list_issues'
assert_not_nil assigns(:issues)
end
def test_export_issues_csv
get :export_issues_csv, :id => 1
assert_response :success
assert_not_nil assigns(:issues)
end
def test_bulk_edit_issues
@ -150,7 +123,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_response :success
assert_template 'add_issue'
post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5}
assert_redirected_to 'projects/list_issues'
assert_redirected_to 'projects/1/issues'
assert Issue.find_by_subject('This is the test_add_issue issue')
end

@ -24,7 +24,7 @@ class IssuesTest < ActionController::IntegrationTest
assert_kind_of Issue, issue
# check redirection
assert_redirected_to "projects/list_issues/1"
assert_redirected_to "projects/1/issues"
follow_redirect!
assert assigns(:issues).include?(issue)

Loading…
Cancel
Save