]> source.dussan.org Git - redmine.git/commitdiff
Merged IssuesController#export_pdf into IssuesController#show.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 5 Oct 2007 23:17:49 +0000 (23:17 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 5 Oct 2007 23:17:49 +0000 (23:17 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@810 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/views/issues/_pdf.rfpdf
app/views/issues/export_pdf.rfpdf [deleted file]
app/views/issues/show.rfpdf [new file with mode: 0644]
app/views/issues/show.rhtml
lib/redmine.rb

index 716816e34ec522315a5675456e48d8d9ce138da8..d8fd95b6a50f8f1643421982056d9b6e553048e5 100644 (file)
@@ -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
index 485066894eb014d1c1cf1ee9b3bf952084057aa4..558399abb1197800f9c017837ae9f73f95d3214e 100644 (file)
@@ -70,7 +70,7 @@
     pdf.SetFontStyle('B',9)\r
     pdf.Cell(190,5, l(:label_history), "B")\r
     pdf.Ln     \r
-       for journal in issue.journals.find(:all, :include => :user, :order => "journals.created_on desc")\r
+       for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")\r
                pdf.SetFontStyle('B',8)\r
            pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)\r
            pdf.Ln\r
                pdf.Ln\r
        end\r
        \r
-    pdf.SetFontStyle('B',9)\r
-    pdf.Cell(190,5, l(:label_attachment_plural), "B")\r
-       pdf.Ln\r
-       for attachment in issue.attachments\r
-               pdf.SetFontStyle('',8)\r
-           pdf.Cell(80,5, attachment.filename)\r
-               pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")\r
-               pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R")\r
-               pdf.Cell(65,5, attachment.author.name,0,0,"R")\r
+       if issue.attachments.any?\r
+           pdf.SetFontStyle('B',9)\r
+           pdf.Cell(190,5, l(:label_attachment_plural), "B")\r
                pdf.Ln\r
+               for attachment in issue.attachments\r
+                       pdf.SetFontStyle('',8)\r
+                   pdf.Cell(80,5, attachment.filename)\r
+                       pdf.Cell(20,5, number_to_human_size(attachment.filesize),0,0,"R")\r
+                       pdf.Cell(25,5, format_date(attachment.created_on),0,0,"R")\r
+                       pdf.Cell(65,5, attachment.author.name,0,0,"R")\r
+                       pdf.Ln\r
+               end\r
        end\r
-%>
\ No newline at end of file
+%>\r
diff --git a/app/views/issues/export_pdf.rfpdf b/app/views/issues/export_pdf.rfpdf
deleted file mode 100644 (file)
index 51a71c0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<%     pdf=IfpdfHelper::IFPDF.new(current_language)\r
-       pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")\r
-       pdf.AliasNbPages\r
-       pdf.footer_date = format_date(Date.today)\r
-       pdf.AddPage\r
-       \r
-       render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue }\r
-%>\r
-\r
-<%= pdf.Output %>
\ No newline at end of file
diff --git a/app/views/issues/show.rfpdf b/app/views/issues/show.rfpdf
new file mode 100644 (file)
index 0000000..08f2cb9
--- /dev/null
@@ -0,0 +1,10 @@
+<%     pdf=IfpdfHelper::IFPDF.new(current_language)\r
+       pdf.SetTitle("#{@project.name} - ##{@issue.tracker.name} #{@issue.id}")\r
+       pdf.AliasNbPages\r
+       pdf.footer_date = format_date(Date.today)\r
+       pdf.AddPage\r
+       \r
+       render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue }\r
+%>\r
+\r
+<%= pdf.Output %>\r
index 9075df9f92835557e3a59815aa76644dc11ba2c4..ed615c69f26627b50e23b4ed29fe8530b6c38547 100644 (file)
@@ -111,7 +111,7 @@ end %>
 <% end %>
 
 <div class="contextual">
-<%= 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' %>
 </div>
 &nbsp;
 
index 7217abe16fefa3f820d44faac6465a6d15e727f1..f5682a9593941e2f5987945ac1985c658d107fab 100644 (file)
@@ -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