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-8f06a7374b81pull/351/head
parent
26a1ae4808
commit
8509cf80f0
@ -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,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 /> |
||||
|
||||
<% 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 /> |
||||
|
||||
<%= 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 %> |
||||
|
||||
<% 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 /> |
||||
|
||||
<% 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({})' %> |
@ -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 |
Loading…
Reference in new issue