diff options
-rw-r--r-- | app/controllers/issues_controller.rb | 95 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 142 | ||||
-rw-r--r-- | app/controllers/queries_controller.rb | 4 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 52 | ||||
-rw-r--r-- | app/models/journal.rb | 4 | ||||
-rw-r--r-- | app/views/issues/_sidebar.rhtml | 4 | ||||
-rw-r--r-- | app/views/issues/changes.rxml | 30 | ||||
-rw-r--r-- | app/views/issues/context_menu.rhtml | 2 | ||||
-rw-r--r-- | app/views/issues/index.rfpdf (renamed from app/views/projects/export_issues_pdf.rfpdf) | 97 | ||||
-rw-r--r-- | app/views/issues/index.rhtml | 79 | ||||
-rw-r--r-- | app/views/projects/list_issues.rhtml | 72 | ||||
-rw-r--r-- | app/views/projects/roadmap.rhtml | 4 | ||||
-rw-r--r-- | app/views/projects/show.rhtml | 4 | ||||
-rw-r--r-- | app/views/queries/index.rhtml | 2 | ||||
-rw-r--r-- | app/views/reports/_details.rhtml | 10 | ||||
-rw-r--r-- | app/views/reports/_simple.rhtml | 8 | ||||
-rw-r--r-- | config/environment.rb | 5 | ||||
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | lib/redmine.rb | 6 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 86 | ||||
-rw-r--r-- | test/functional/projects_controller_test.rb | 29 | ||||
-rw-r--r-- | test/integration/issues_test.rb | 2 |
22 files changed, 376 insertions, 362 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 228597931..602d551f3 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.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 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ae9c242e0..4356ec774 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb index 72819bd68..7feafd35b 100644 --- a/app/controllers/queries_controller.rb +++ b/app/controllers/queries_controller.rb @@ -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 diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 997f094a4..c779c9d16 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -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 diff --git a/app/models/journal.rb b/app/models/journal.rb index a68988a7b..331d7a729 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -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 diff --git a/app/views/issues/_sidebar.rhtml b/app/views/issues/_sidebar.rhtml index b171dbd0b..3b42ce465 100644 --- a/app/views/issues/_sidebar.rhtml +++ b/app/views/issues/_sidebar.rhtml @@ -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 %> diff --git a/app/views/issues/changes.rxml b/app/views/issues/changes.rxml new file mode 100644 index 000000000..f1aa5d206 --- /dev/null +++ b/app/views/issues/changes.rxml @@ -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
\ No newline at end of file diff --git a/app/views/issues/context_menu.rhtml b/app/views/issues/context_menu.rhtml index 798fd42c3..e44911daf 100644 --- a/app/views/issues/context_menu.rhtml +++ b/app/views/issues/context_menu.rhtml @@ -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> diff --git a/app/views/projects/export_issues_pdf.rfpdf b/app/views/issues/index.rfpdf index d782c54b0..d5a8d3c31 100644 --- a/app/views/projects/export_issues_pdf.rfpdf +++ b/app/views/issues/index.rfpdf @@ -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 %>
\ No newline at end of file diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index eb0835357..81c59ca55 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -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({})' %> diff --git a/app/views/projects/list_issues.rhtml b/app/views/projects/list_issues.rhtml deleted file mode 100644 index 0c0aaa418..000000000 --- a/app/views/projects/list_issues.rhtml +++ /dev/null @@ -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({})' %> diff --git a/app/views/projects/roadmap.rhtml b/app/views/projects/roadmap.rhtml index 8d681657e..d45bc207c 100644 --- a/app/views/projects/roadmap.rhtml +++ b/app/views/projects/roadmap.rhtml @@ -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 %>%)   - <%= 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 %>%)   + <%= 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 %> diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index 25fbe3c68..88178cb5d 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -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> diff --git a/app/views/queries/index.rhtml b/app/views/queries/index.rhtml index 71aa37497..1c608b8ac 100644 --- a/app/views/queries/index.rhtml +++ b/app/views/queries/index.rhtml @@ -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> diff --git a/app/views/reports/_details.rhtml b/app/views/reports/_details.rhtml index af8807fbd..c3ad2bed7 100644 --- a/app/views/reports/_details.rhtml +++ b/app/views/reports/_details.rhtml @@ -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> diff --git a/app/views/reports/_simple.rhtml b/app/views/reports/_simple.rhtml index 8b5a7fe47..7f799f325 100644 --- a/app/views/reports/_simple.rhtml +++ b/app/views/reports/_simple.rhtml @@ -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> diff --git a/config/environment.rb b/config/environment.rb index c7e0e47a9..69d469282 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index bb61b4c0f..3b4767a33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/lib/redmine.rb b/lib/redmine.rb index bf6d63059..3e9569ac2 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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? } diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb new file mode 100644 index 000000000..484ebc62b --- /dev/null +++ b/test/functional/issues_controller_test.rb @@ -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 diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 86cea62f8..28f826b8b 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -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 diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 668bcbd18..eac407b1b 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -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) |