changeset 1367:a2e51c0a7860 luisf

Correctly clears the cache when publication authors' order is changed.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 19 Aug 2013 16:33:09 +0100
parents 7e85f7988ab8
children 987e71e73116 c28ce1a71a22 6ba24edae331
files plugins/redmine_bibliography/app/models/authorship.rb
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/models/authorship.rb	Mon Aug 19 16:23:24 2013 +0100
+++ b/plugins/redmine_bibliography/app/models/authorship.rb	Mon Aug 19 16:33:09 2013 +0100
@@ -12,6 +12,7 @@
   attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author
 
   before_create :associate_author_user
+  before_update :delete_publication_cache
 
   # tod: review scope of ordering
   acts_as_list :column => 'auth_order'
@@ -46,10 +47,14 @@
   end
 
   protected
+
+  def delete_publication_cache
+    publication = Publication.find(self.publication_id)
+    Rails.cache.delete "publication-#{publication.id}-ieee"
+    Rails.cache.delete "publication-#{publication.id}-bibtex"
+  end
+
   def associate_author_user
-
-    logger.error { "search_author_class '#{self.search_author_class}'" }
-
     case self.search_author_class
     when ""
       logger.debug { "Unknown Author to be added..." }