changeset 560:735388da579a feature_36

Fixes Issues #246 and #247.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 04 Aug 2011 15:35:54 +0100
parents 3c9ca235835b
children 9d786d8d3b1f
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb
diffstat 3 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Aug 03 18:19:47 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Aug 04 15:35:54 2011 +0100
@@ -3,6 +3,9 @@
 class PublicationsController < ApplicationController
   unloadable
   
+  model_object Publication
+  before_filter :find_model_object, :except => [:new, :create, :index]
+  
   # before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author]
     
   def new
@@ -252,6 +255,14 @@
     
   end
   
+  def destroy
+    find_project_by_project_id
+    
+    @publication.destroy
+        
+    flash[:notice] = "Successfully deleted Publication."
+    redirect_to :controller => :publications, :action => 'index', :project_id => @project
+  end
 
   def identify_author
     
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Wed Aug 03 18:19:47 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Thu Aug 04 15:35:54 2011 +0100
@@ -6,7 +6,7 @@
   has_many :authorships, :dependent => :destroy
   has_many :authors, :through => :authorships, :uniq => true
   
-  has_one :bibtex_entry
+  has_one :bibtex_entry, :dependent => :destroy
 
   validates_presence_of :title
 
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Wed Aug 03 18:19:47 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb	Thu Aug 04 15:35:54 2011 +0100
@@ -26,7 +26,8 @@
 
 <p>
   <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> |
-  <%= link_to "Destroy", @publication, :confirm => 'Are you sure?', :method => :delete %> |
+  <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project },
+                                                     :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> |
   <%= link_to "View All", publications_path %>
 </p>
 </div>