diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9c16d299..cec126dd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -18,6 +18,8 @@ class IssuesController < ApplicationController layout 'base', :except => :export_pdf before_filter :find_project, :authorize + + cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ] helper :custom_fields include CustomFieldsHelper diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a870cca2..ca6ea8d8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -21,6 +21,8 @@ class ProjectsController < ApplicationController layout 'base' before_filter :find_project, :authorize, :except => [ :index, :list, :add ] before_filter :require_admin, :only => [ :add, :destroy ] + + cache_sweeper :issue_sweeper, :only => [ :add_issue ] helper :sort include SortHelper diff --git a/app/sweepers/issue_sweeper.rb b/app/sweepers/issue_sweeper.rb new file mode 100644 index 00000000..dc902053 --- /dev/null +++ b/app/sweepers/issue_sweeper.rb @@ -0,0 +1,38 @@ +# 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. + +class IssueSweeper < ActionController::Caching::Sweeper + observe Issue + + def after_save(issue) + expire_cache_for(issue) + end + + def after_destroy(issue) + expire_cache_for(issue) + end + +private + def expire_cache_for(issue) + # fragments of the main project + expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project_id}\\.")) + # fragments of the root project that include subprojects issues + unless issue.project.parent_id.nil? + expire_fragment(Regexp.new("projects/(calendar|gantt)/#{issue.project.parent_id}\\..*subprojects")) + end + end +end diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml index c63365b6..2a53831f 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -1,3 +1,4 @@ +<% cache(:year => @year, :month => @month, :tracker_ids => @selected_tracker_ids, :subprojects => params[:with_subprojects], :lang => current_language) do %>
@@ -171,14 +172,6 @@ if show_days
end
end %>
-<%
-#
-# Today red line
-#
-if Date.today >= @date_from and Date.today <= @date_to %>
- |
<%= link_to ('« ' + l(:label_previous)), :year => (@date_from << @months).year, :month => (@date_from << @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %> | <%= link_to (l(:label_next) + ' »'), :year => (@date_from >> @months).year, :month => (@date_from >> @months).month, :zoom => @zoom, :months => @months, :tracker_ids => @selected_tracker_ids, :with_subprojects => params[:with_subprojects] %> | -