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
This commit is contained in:
Jean-Philippe Lang 2007-11-05 18:38:42 +00:00
parent 26a1ae4808
commit 8509cf80f0
22 changed files with 377 additions and 363 deletions

View File

@ -16,9 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssuesController < ApplicationController class IssuesController < ApplicationController
layout 'base', :except => :export_pdf layout 'base'
before_filter :find_project, :authorize, :except => [:index, :preview] before_filter :find_project, :authorize, :except => [:index, :changes, :preview]
accept_key_auth :index before_filter :find_optional_project, :only => [:index, :changes]
accept_key_auth :index, :changes
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ] cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
@ -37,37 +38,54 @@ class IssuesController < ApplicationController
helper :queries helper :queries
helper :sort helper :sort
include SortHelper include SortHelper
include IssuesHelper
def index def index
sort_init "#{Issue.table_name}.id", "desc" sort_init "#{Issue.table_name}.id", "desc"
sort_update sort_update
retrieve_query retrieve_query
if @query.valid? if @query.valid?
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_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
@issue_pages = Paginator.new self, @issue_count, 25, params['page'] @issue_pages = Paginator.new self, @issue_count, limit, params['page']
@issues = Issue.find :all, :order => sort_clause, @issues = Issue.find :all, :order => sort_clause,
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category ], :include => [ :assigned_to, :status, :tracker, :project, :priority, :category ],
:conditions => @query.statement, :conditions => @query.statement,
:limit => @issue_pages.items_per_page, :limit => limit,
:offset => @issue_pages.current.offset :offset => @issue_pages.current.offset
end
respond_to do |format| respond_to do |format|
format.html { render :layout => false if request.xhr? } format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
format.atom { render_feed(@issues, :title => l(:label_issue_plural)) } 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 end
else
# Send html if the query is not valid
render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
end
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 end
def show def show
@custom_values = @issue.custom_values.find(:all, :include => :custom_field) @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") @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 @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' 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
end end
@ -152,7 +170,7 @@ class IssuesController < ApplicationController
def destroy def destroy
@issue.destroy @issue.destroy
redirect_to :controller => 'projects', :action => 'list_issues', :id => @project redirect_to :action => 'index', :project_id => @project
end end
def destroy_attachment def destroy_attachment
@ -195,11 +213,25 @@ private
render_404 render_404
end 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 # Retrieve query from session or build a new query
def retrieve_query def retrieve_query
if params[:set_filter] or !session[:query] or session[:query].project_id 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 # Give it a name, required to be valid
@query = Query.new(:name => "_", :executed_by => logged_in_user) @query = Query.new(:name => "_", :executed_by => logged_in_user)
@query.project = @project
if params[:fields] and params[:fields].is_a? Array if params[:fields] and params[:fields].is_a? Array
params[:fields].each do |field| params[:fields].each do |field|
@query.add_filter(field, params[:operators][field], params[:values][field]) @query.add_filter(field, params[:operators][field], params[:values][field])
@ -215,3 +247,4 @@ private
end end
end end
end end
end

View File

@ -15,8 +15,6 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'csv'
class ProjectsController < ApplicationController class ProjectsController < ApplicationController
layout 'base' layout 'base'
before_filter :find_project, :except => [ :index, :list, :add ] before_filter :find_project, :except => [ :index, :list, :add ]
@ -238,118 +236,13 @@ class ProjectsController < ApplicationController
end end
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added') 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 return
end end
end end
@priorities = Enumeration::get_values('IPRI') @priorities = Enumeration::get_values('IPRI')
end 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 # Bulk edit issues
def bulk_edit_issues def bulk_edit_issues
if request.post? if request.post?
@ -383,7 +276,7 @@ class ProjectsController < ApplicationController
else else
flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #')) flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, issues.size, '#' + unsaved_issue_ids.join(', #'))
end end
redirect_to :action => 'list_issues', :id => @project redirect_to :controller => 'issues', :action => 'index', :project_id => @project
return return
end end
if current_role && User.current.allowed_to?(:change_issue_status, @project) if current_role && User.current.allowed_to?(:change_issue_status, @project)
@ -399,7 +292,7 @@ class ProjectsController < ApplicationController
def move_issues def move_issues
@issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] @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 = [] @projects = []
# find projects to which the user is allowed to move the issue # 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')} 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 i.save
end end
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'list_issues', :id => @project redirect_to :controller => 'issues', :action => 'index', :project_id => @project
end end
end end
@ -659,31 +552,4 @@ private
@selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s } @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
end end
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 end

View File

@ -39,7 +39,7 @@ class QueriesController < ApplicationController
if request.post? && params[:confirm] && @query.save if request.post? && params[:confirm] && @query.save
flash[:notice] = l(:notice_successful_create) 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 return
end end
render :layout => false if request.xhr? render :layout => false if request.xhr?
@ -57,7 +57,7 @@ class QueriesController < ApplicationController
if @query.save if @query.save
flash[:notice] = l(:notice_successful_update) 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 end
end end

View File

@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'csv'
module IssuesHelper module IssuesHelper
def render_issue_tooltip(issue) def render_issue_tooltip(issue)
@ -101,4 +103,54 @@ module IssuesHelper
end end
end 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 end

View File

@ -29,6 +29,10 @@ class Journal < ActiveRecord::Base
:project_key => "#{Issue.table_name}.project_id", :project_key => "#{Issue.table_name}.project_id",
:date_column => "#{Issue.table_name}.created_on" :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 def save
# Do not save an empty journal # Do not save an empty journal
(details.empty? && notes.blank?) ? false : super (details.empty? && notes.blank?) ? false : super

View File

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

View File

@ -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

View File

@ -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> <ul>
<li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, <li><%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue},
:class => 'icon-edit', :disabled => !@can[:edit] %></li> :class => 'icon-edit', :disabled => !@can[:edit] %></li>

View File

@ -1,5 +1,6 @@
<% pdf=IfpdfHelper::IFPDF.new(current_language) <% pdf=IfpdfHelper::IFPDF.new(current_language)
pdf.SetTitle("#{@project.name} - #{l(:label_issue_plural)}") title = @project ? "#{@project.name} - #{l(:label_issue_plural)}" : "#{l(:label_issue_plural)}"
pdf.SetTitle(title)
pdf.AliasNbPages pdf.AliasNbPages
pdf.footer_date = format_date(Date.today) pdf.footer_date = format_date(Date.today)
pdf.AddPage("L") pdf.AddPage("L")
@ -9,7 +10,7 @@
# title # title
# #
pdf.SetFontStyle('B',11) pdf.SetFontStyle('B',11)
pdf.Cell(190,10, "#{@project.name} - #{l(:label_issue_plural)}") pdf.Cell(190,10, title)
pdf.Ln pdf.Ln
# #
@ -21,7 +22,7 @@
pdf.Cell(30, row_height, l(:field_tracker), 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_status), 0, 0, 'L', 1)
pdf.Cell(30, row_height, l(:field_priority), 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(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(25, row_height, l(:field_updated_on), 0, 0, 'L', 1)
pdf.Cell(0, row_height, l(:field_subject), 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.Line(10, pdf.GetY, 287, pdf.GetY)
@ -39,7 +40,7 @@
pdf.Cell(30, row_height, issue.tracker.name, 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.status.name, 0, 0, 'L', 1)
pdf.Cell(30, row_height, issue.priority.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(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.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.MultiCell(0, row_height, (@project == issue.project ? issue.subject : "#{issue.project.name} - #{issue.subject}"))
pdf.Line(10, pdf.GetY, 287, pdf.GetY) pdf.Line(10, pdf.GetY, 287, pdf.GetY)

View File

@ -1,8 +1,9 @@
<% if @query.new_record? %>
<h2><%=l(:label_issue_plural)%></h2> <h2><%=l(:label_issue_plural)%></h2>
<% set_html_title l(:label_issue_plural) %>
<% form_tag({}, :id => 'query_form') do %> <% form_tag({ :controller => 'queries', :action => 'new', :project_id => @project }, :id => 'query_form') do %>
<%= render :partial => 'queries/filters', :locals => {:query => @query} %> <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
<% end %>
<div class="contextual"> <div class="contextual">
<%= link_to_remote l(:button_apply), <%= link_to_remote l(:button_apply),
{ :url => { :set_filter => 1 }, { :url => { :set_filter => 1 },
@ -14,22 +15,58 @@
{ :url => { :set_filter => 1 }, { :url => { :set_filter => 1 },
:update => "content", :update => "content",
}, :class => 'icon icon-reload' %> }, :class => 'icon icon-reload' %>
</div>
<br />&nbsp;
<% 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 %>
<%= error_messages_for 'query' %> <%= error_messages_for 'query' %>
<% if @query.valid? %> <% if @query.valid? %>
<% if @issues.empty? %> <% if @issues.empty? %>
<p><i><%= l(:label_no_data) %></i></p> <p class="nodata"><%= l(:label_no_data) %></p>
<% else %> <% 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} %> <%= 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 %> <p><%= pagination_links_full @issue_pages %>
[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]</p> [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]</p>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
<% content_for :sidebar do %>
<%= render :partial => 'issues/sidebar' %>
<% end if @project%>
<% content_for :header_tags do %> <% 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 %> <% end %>
<div id="context-menu" style="display: none;"></div>
<%= javascript_tag 'new ContextMenu({})' %>

View File

@ -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({})' %>

View File

@ -34,8 +34,8 @@
<% end %> <% end %>
</tr> </tr>
</table> </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; <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 => 'projects', :action => 'list_issues', :id => @project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %> <%= lwr(:label_open_issues, total - complete)%> (<%= percentIncomplete %>%)</em> <%= 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 />
<br /> <br />
<%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %> <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>

View File

@ -22,14 +22,14 @@
<h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3> <h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3>
<ul> <ul>
<% for tracker in @trackers %> <% 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, :set_filter => 1,
"tracker_id" => tracker.id %>: "tracker_id" => tracker.id %>:
<%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> <%= @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> <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li>
<% end %> <% end %>
</ul> </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> </div>
<% end %> <% end %>
</div> </div>

View File

@ -11,7 +11,7 @@
<% @queries.each do |query| %> <% @queries.each do |query| %>
<tr class="<%= cycle('odd', 'even') %>"> <tr class="<%= cycle('odd', 'even') %>">
<td> <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>
<td align="right"> <td align="right">
<small> <small>

View File

@ -15,28 +15,28 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <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, :set_filter => 1,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<% for status in @statuses %> <% for status in @statuses %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, <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, :set_filter => 1,
"status_id" => status.id, "status_id" => status.id,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<% end %> <% end %>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "o" %></td> "status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "c" %></td> "status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "*" %></td> "status_id" => "*" %></td>

View File

@ -11,21 +11,21 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <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, :set_filter => 1,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "o" %></td> "status_id" => "o" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "c" %></td> "status_id" => "c" %></td>
<td align="center"><%= aggregate_link data, { field_name => row.id }, <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, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "*" %></td> "status_id" => "*" %></td>

View File

@ -78,6 +78,9 @@ ActiveRecord::Errors.default_error_messages = {
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } 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.set_config :default_language => :en
GLoc.clear_strings GLoc.clear_strings
GLoc.set_kcode GLoc.set_kcode

View File

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

View File

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

View File

@ -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

View File

@ -57,33 +57,6 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_not_nil assigns(:grouped) assert_not_nil assigns(:grouped)
end 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 def test_bulk_edit_issues
@request.session[:user_id] = 2 @request.session[:user_id] = 2
# update issues priority # update issues priority
@ -150,7 +123,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_response :success assert_response :success
assert_template 'add_issue' 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} 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') assert Issue.find_by_subject('This is the test_add_issue issue')
end end

View File

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