annotate app/controllers/.svn/text-base/gantts_controller.rb.svn-base @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents cca12e1c1fd4
children 1d32c0a0efbf
rev   line source
Chris@0 1 class GanttsController < ApplicationController
Chris@0 2 before_filter :find_optional_project
Chris@0 3
Chris@0 4 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
Chris@0 5
Chris@0 6 helper :issues
Chris@0 7 helper :projects
Chris@0 8 helper :queries
Chris@0 9 include QueriesHelper
Chris@0 10 helper :sort
Chris@0 11 include SortHelper
Chris@0 12 include Redmine::Export::PDF
Chris@0 13
Chris@0 14 def show
Chris@0 15 @gantt = Redmine::Helpers::Gantt.new(params)
Chris@0 16 retrieve_query
Chris@0 17 @query.group_by = nil
Chris@0 18 if @query.valid?
Chris@0 19 events = []
Chris@0 20 # Issues that have start and due dates
Chris@0 21 events += @query.issues(:include => [:tracker, :assigned_to, :priority],
Chris@0 22 :order => "start_date, due_date",
Chris@0 23 :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
Chris@0 24 )
Chris@0 25 # Issues that don't have a due date but that are assigned to a version with a date
Chris@0 26 events += @query.issues(:include => [:tracker, :assigned_to, :priority, :fixed_version],
Chris@0 27 :order => "start_date, effective_date",
Chris@0 28 :conditions => ["(((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
Chris@0 29 )
Chris@0 30 # Versions
Chris@0 31 events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
Chris@0 32
Chris@0 33 @gantt.events = events
Chris@0 34 end
Chris@0 35
Chris@0 36 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
Chris@0 37
Chris@0 38 respond_to do |format|
Chris@0 39 format.html { render :action => "show", :layout => !request.xhr? }
Chris@1 40 format.png { send_data(@gantt.to_image(@project), :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
Chris@0 41 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") }
Chris@0 42 end
Chris@0 43 end
Chris@0 44
Chris@0 45 end