Diff
Modified: branches/packs/app/controllers/packs_controller.rb (3692 => 3693)
--- branches/packs/app/controllers/packs_controller.rb 2013-09-06 21:24:57 UTC (rev 3692)
+++ branches/packs/app/controllers/packs_controller.rb 2013-09-06 21:26:06 UTC (rev 3693)
@@ -17,7 +17,7 @@
"http://purl.org/wf4ever/roterms#ExampleRun",
"http://purl.org/wf4ever/roterms#ProspectiveRun"]
- before_filter :login_required, :except => [:index, :show, :search, :items, :download, :statistics, :item_show, :item_destroy]
+ before_filter :login_required, :except => [:index, :show, :search, :items, :download, :statistics]
before_filter :find_pack_auth, :except => [:index, :new, :create, :search]
@@ -498,8 +498,6 @@
"favourite_delete" => "view",
"index" => "view",
"items" => "view",
- "item_destroy" => "edit",
- "item_show" => "view",
"new" => "create",
"new_item" => "edit",
"quick_add" => "edit",
Modified: branches/packs/app/models/pack.rb (3692 => 3693)
--- branches/packs/app/models/pack.rb 2013-09-06 21:24:57 UTC (rev 3692)
+++ branches/packs/app/models/pack.rb 2013-09-06 21:26:06 UTC (rev 3693)
@@ -10,6 +10,7 @@
require 'tempfile'
require 'cgi'
require 'sunspot_rails'
+require 'has_research_object'
class Pack < ActiveRecord::Base
@@ -32,7 +33,7 @@
belongs_to :license
- has_one :research_object, :as => 'context', :dependent => :destroy
+ has_research_object
def find_version(version)
match = versions.find(:first, :conditions => ["version = ?", version])
@@ -714,14 +715,6 @@
return ""
end
- def find_resource_by_path(path)
- research_object.resources.find_by_path(relative_uri(path, research_object.uri))
- end
-
- def find_resource_by_ore_path(path)
- research_object.find_using_path(relative_uri(path, research_object.uri))
- end
-
protected
# produces html string containing the required messaged, enclosed within left-padded P tag, belonging to 'none_text' class
Modified: branches/packs/app/models/pack_contributable_entry.rb (3692 => 3693)
--- branches/packs/app/models/pack_contributable_entry.rb 2013-09-06 21:24:57 UTC (rev 3692)
+++ branches/packs/app/models/pack_contributable_entry.rb 2013-09-06 21:26:06 UTC (rev 3693)
@@ -3,6 +3,8 @@
# Copyright (c) 2008 University of Manchester and the University of Southampton.
# See license.txt for details.
+require 'has_research_object'
+
class PackContributableEntry < ActiveRecord::Base
belongs_to :pack
validates_presence_of :pack
@@ -22,7 +24,7 @@
after_save :synchronize_research_object
- has_one :resource, :as => :context, :dependent => :destroy
+ has_resource
def check_unique
Modified: branches/packs/app/models/pack_remote_entry.rb (3692 => 3693)
--- branches/packs/app/models/pack_remote_entry.rb 2013-09-06 21:24:57 UTC (rev 3692)
+++ branches/packs/app/models/pack_remote_entry.rb 2013-09-06 21:26:06 UTC (rev 3693)
@@ -3,6 +3,8 @@
# Copyright (c) 2008 University of Manchester and the University of Southampton.
# See license.txt for details.
+require 'has_research_object'
+
class PackRemoteEntry < ActiveRecord::Base
belongs_to :pack
validates_presence_of :pack
@@ -20,7 +22,7 @@
after_save :synchronize_research_object
- has_one :resource, :as => :context, :dependent => :destroy
+ has_resource
def check_unique
if PackRemoteEntry.find(:first, :conditions => ["pack_id = ? AND version = ? AND uri = ?", self.pack_id, self.version, self.uri])
Added: branches/packs/lib/has_research_object.rb (0 => 3693)
--- branches/packs/lib/has_research_object.rb (rev 0)
+++ branches/packs/lib/has_research_object.rb 2013-09-06 21:26:06 UTC (rev 3693)
@@ -0,0 +1,24 @@
+# myExperiment: lib/has_research_object.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton. See license.txt for details.
+
+class ActiveRecord::Base
+
+ def self.has_research_object
+ has_one :research_object, :as => 'context', :dependent => :destroy
+ end
+
+ def self.has_resource
+ has_one :resource, :as => :context, :dependent => :destroy
+ end
+
+ def find_resource_by_path(path)
+ research_object.resources.find_by_path(relative_uri(path, research_object.uri))
+ end
+
+ def find_resource_by_ore_path(path)
+ research_object.find_using_path(relative_uri(path, research_object.uri))
+ end
+
+end