diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-11 17:03:26 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-09-11 17:03:26 +0000 |
commit | 586f4e3831e31aef7d2a0e837c1c9fb6fc5c52ce (patch) | |
tree | 0f46ca47ee28d06f272e476242aab69487e2fbf9 /app/controllers | |
parent | 2986afc05ed5154b059e1408f32436a97e54f272 (diff) | |
download | redmine-586f4e3831e31aef7d2a0e837c1c9fb6fc5c52ce.tar.gz redmine-586f4e3831e31aef7d2a0e837c1c9fb6fc5c52ce.zip |
Adds support for free ticket filtering and custom queries on Calendar.
ProjectsController#calendar moved to IssuesController.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1798 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/issues_controller.rb | 33 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 30 |
2 files changed, 31 insertions, 32 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 43a04f26d..7d39e4552 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2008 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 @@ -20,7 +20,7 @@ class IssuesController < ApplicationController before_filter :find_issue, :only => [:show, :edit, :reply, :destroy_attachment] before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] - before_filter :find_project, :only => [:new, :update_form, :preview, :gantt] + before_filter :find_project, :only => [:new, :update_form, :preview, :gantt, :calendar] before_filter :authorize, :except => [:index, :changes, :preview, :update_form, :context_menu] before_filter :find_optional_project, :only => [:index, :changes] accept_key_auth :index, :changes @@ -354,6 +354,33 @@ class IssuesController < ApplicationController end end + def calendar + if params[:year] and params[:year].to_i > 1900 + @year = params[:year].to_i + if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 + @month = params[:month].to_i + end + end + @year ||= Date.today.year + @month ||= Date.today.month + + @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) + retrieve_query + if @query.valid? + events = [] + events += Issue.find(:all, + :include => [:tracker, :status, :assigned_to, :priority, :project], + :conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] + ) + events += Version.find(:all, :include => :project, + :conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) + + @calendar.events = events + end + + render :layout => false if request.xhr? + end + def context_menu @issues = Issue.find_all_by_id(params[:ids], :include => :project) if (@issues.size == 1) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9e1df29a2..fc33336a0 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -27,7 +27,7 @@ class ProjectsController < ApplicationController before_filter :find_optional_project, :only => :activity before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy, :activity ] before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] - accept_key_auth :activity, :calendar + accept_key_auth :activity helper :sort include SortHelper @@ -246,34 +246,6 @@ class ProjectsController < ApplicationController end end - def calendar - @trackers = @project.rolled_up_trackers - retrieve_selected_tracker_ids(@trackers) - - if params[:year] and params[:year].to_i > 1900 - @year = params[:year].to_i - if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 - @month = params[:month].to_i - end - end - @year ||= Date.today.year - @month ||= Date.today.month - @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month) - @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') - events = [] - @project.issues_with_subprojects(@with_subprojects) do - events += Issue.find(:all, - :include => [:tracker, :status, :assigned_to, :priority, :project], - :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt] - ) unless @selected_tracker_ids.empty? - events += Version.find(:all, :include => :project, - :conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt]) - end - @calendar.events = events - - render :layout => false if request.xhr? - end - private # Find project of id params[:id] # if not found, redirect to project list |