myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3687] trunk/config: Added content types loader


From: noreply
Subject: [myexperiment-hackers] [3687] trunk/config: Added content types loader
Date: Fri, 6 Sep 2013 13:45:29 +0000 (UTC)

Revision
3687
Author
fbacall
Date
2013-09-06 13:45:29 +0000 (Fri, 06 Sep 2013)

Log Message

Added content types loader

Added Paths

Diff

Added: trunk/config/content_types.yml (0 => 3687)


--- trunk/config/content_types.yml	                        (rev 0)
+++ trunk/config/content_types.yml	2013-09-06 13:45:29 UTC (rev 3687)
@@ -0,0 +1,4 @@
+component_profile:
+  title: Taverna Component Profile
+  mime_type: application/vnd.taverna.component-profile+xml
+  category: Blob
\ No newline at end of file

Added: trunk/config/initializers/default_content_types.rb (0 => 3687)


--- trunk/config/initializers/default_content_types.rb	                        (rev 0)
+++ trunk/config/initializers/default_content_types.rb	2013-09-06 13:45:29 UTC (rev 3687)
@@ -0,0 +1,18 @@
+# myExperiment: config/initializers/content_types.rb
+#
+# Copyright (c) 2013 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+# Loads a set default content_types into the database
+
+content_types = YAML::load_file("config/content_types.yml")
+
+Rails.logger.debug('Loading content types...')
+ContentType.transaction do
+  content_types.each do |k,v|
+    unless ContentType.find_by_title_and_mime_type_and_category(v['title'], v['mime_type'], v['category'])
+      Rails.logger.debug("\tCreating content type #{v['title']}: #{v['mime_type']}")
+      ContentType.create(v)
+    end
+  end
+end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]