From fa094a3fe5f8ae0ae03214a080280c64f51bd6b0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 5 Oct 2007 23:17:49 +0000 Subject: [PATCH] Merged IssuesController#export_pdf into IssuesController#show. git-svn-id: http://redmine.rubyforge.org/svn/trunk@810 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 16 +++++++------ app/views/issues/_pdf.rfpdf | 24 ++++++++++--------- .../issues/{export_pdf.rfpdf => show.rfpdf} | 2 +- app/views/issues/show.rhtml | 2 +- lib/redmine.rb | 2 +- 5 files changed, 25 insertions(+), 21 deletions(-) rename app/views/issues/{export_pdf.rfpdf => show.rfpdf} (90%) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 716816e34..d8fd95b6a 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -58,15 +58,17 @@ class IssuesController < ApplicationController end def show - @status_options = @issue.status.find_new_statuses_allowed_to(logged_in_user.role_for_project(@project), @issue.tracker) if logged_in_user @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") - end - - def export_pdf - @custom_values = @issue.custom_values.find(:all, :include => :custom_field) - @options_for_rfpdf ||= {} - @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.id}.pdf" + + 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' + end end def edit diff --git a/app/views/issues/_pdf.rfpdf b/app/views/issues/_pdf.rfpdf index 485066894..558399abb 100644 --- a/app/views/issues/_pdf.rfpdf +++ b/app/views/issues/_pdf.rfpdf @@ -70,7 +70,7 @@ pdf.SetFontStyle('B',9) pdf.Cell(190,5, l(:label_history), "B") pdf.Ln - for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc") + for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") pdf.SetFontStyle('B',8) pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name) pdf.Ln @@ -86,15 +86,17 @@ pdf.Ln end - pdf.SetFontStyle('B',9) - pdf.Cell(190,5, l(:label_attachment_plural), "B") - pdf.Ln - for attachment in issue.attachments - pdf.SetFontStyle('',8) - pdf.Cell(80,5, attachment.filename) - pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") - pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") - pdf.Cell(65,5, attachment.author.name,0,0,"R") + if issue.attachments.any? + pdf.SetFontStyle('B',9) + pdf.Cell(190,5, l(:label_attachment_plural), "B") pdf.Ln + for attachment in issue.attachments + pdf.SetFontStyle('',8) + pdf.Cell(80,5, attachment.filename) + pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R") + pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R") + pdf.Cell(65,5, attachment.author.name,0,0,"R") + pdf.Ln + end end -%> \ No newline at end of file +%> diff --git a/app/views/issues/export_pdf.rfpdf b/app/views/issues/show.rfpdf similarity index 90% rename from app/views/issues/export_pdf.rfpdf rename to app/views/issues/show.rfpdf index 51a71c0c1..08f2cb92d 100644 --- a/app/views/issues/export_pdf.rfpdf +++ b/app/views/issues/show.rfpdf @@ -7,4 +7,4 @@ render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue } %> -<%= pdf.Output %> \ No newline at end of file +<%= pdf.Output %> diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index 9075df9f9..ed615c69f 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -111,7 +111,7 @@ end %> <% end %>
-<%= l(:label_export_to) %><%= link_to 'PDF', {:action => 'export_pdf', :id => @issue}, :class => 'icon icon-pdf' %> +<%= l(:label_export_to) %><%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %>
  diff --git a/lib/redmine.rb b/lib/redmine.rb index 7217abe16..f5682a959 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -25,7 +25,7 @@ Redmine::AccessControl.map do |map| 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, :export_pdf], + :issues => :show, :queries => :index, :reports => :issue_report}, :public => true map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin -- 2.39.5