From: Jan Provaznik <[email protected]>

This selection behavior will enhanced with JS in next version.
---
 src/app/models/template.rb                         |    4 ++++
 src/app/util/image_descriptor_xml.rb               |    7 -------
 src/app/views/templates/_basics.haml               |    9 ++++-----
 .../image_descriptor_platform_repositories.yml     |    3 ---
 4 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/app/models/template.rb b/src/app/models/template.rb
index 4af8a02..dec7b4b 100644
--- a/src/app/models/template.rb
+++ b/src/app/models/template.rb
@@ -75,4 +75,8 @@ class Template < ActiveRecord::Base
   def set_complete
     update_attributes(:complete => true, :uploaded => false)
   end
+
+  def platforms
+    @platforms ||= 
YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_platform_repositories.yml")
+  end
 end
diff --git a/src/app/util/image_descriptor_xml.rb 
b/src/app/util/image_descriptor_xml.rb
index f437574..00f8bb2 100644
--- a/src/app/util/image_descriptor_xml.rb
+++ b/src/app/util/image_descriptor_xml.rb
@@ -82,13 +82,6 @@ class ImageDescriptorXML
     get_or_create_node('os')['architecture'] = str
   end
 
-  def platforms
-    unless @platforms
-      @platforms = 
YAML.load_file("#{RAILS_ROOT}/config/image_descriptor_platform_repositories.yml")
-    end
-    return @platforms
-  end
-
   def description=(str)
     node = get_or_create_node('description')
     node.content = str
diff --git a/src/app/views/templates/_basics.haml 
b/src/app/views/templates/_basics.haml
index a26af1b..71a71fe 100644
--- a/src/app/views/templates/_basics.haml
+++ b/src/app/views/templates/_basics.haml
@@ -11,12 +11,11 @@
   %label.grid_4.alpha Choose Logo:
   %input{:type => 'file', :disabled => 'disabled', :class => "grid_7"}
 %fieldset.clearfix
+  - default = @tpl.platforms['fedora']
   = label :tpl, :platform, 'Platform Choice:', :class => "grid_4 alpha"
-  = select :tpl, :platform, @tpl.xml.platforms.map {|id, p| [p['name'], id]}, 
{}, {:class => 'grid_7'}
-  / FIXME: it's currently possible to choose bad os<->version combination, for 
example
-  / RHEL 11, JS will be required to fix this
-  = select :tpl, :platform_version, @tpl.xml.platforms.map {|id, p| 
p['version'].to_s}.sort.uniq, {}, {:class => 'grid_3'}
-  = select :tpl, :architecture, @tpl.xml.platforms.map {|id, p| 
p['architecture']}.sort.uniq, {}, {:class => 'grid_2 omega'}
+  = select :tpl, :platform, @tpl.platforms.map {|id, p| [p['name'], id]}, 
{:selected => @tpl.platform || 'fedora'}, {:class => 'grid_7'}
+  = select :tpl, :platform_version, @tpl.platforms.map {|id, p| 
p['version'].to_s}.sort.uniq, {:selected => @tpl.platform_version || 
default['version']}, {:class => 'grid_3'}
+  = select :tpl, :architecture, @tpl.platforms.map {|id, p| 
p['architecture']}.sort.uniq, {:selected => @tpl.architecture || 
default['architecture']}, {:class => 'grid_2 omega'}
 %fieldset.clearfix
   = label_tag :bootable, 'Bootable:', :class => "grid_4 alpha"
   .grid_12.omega
diff --git a/src/config/image_descriptor_platform_repositories.yml 
b/src/config/image_descriptor_platform_repositories.yml
index 95a8bf9..1e9704f 100644
--- a/src/config/image_descriptor_platform_repositories.yml
+++ b/src/config/image_descriptor_platform_repositories.yml
@@ -2,10 +2,7 @@ fedora:
   name: Fedora
   version: 13
   architecture: 64-bit
-  baseurl: 
http://download.fedoraproject.org/pub/fedora/linux/releases/11/Everything/x86_64/os/
 rhel:
   name: RHEL
   version: 5
   architecture: 64-bit
-  # this should be ignored, it's defined just to be showned in selection tag
-  baseurl: 
http://download.fedoraproject.org/pub/fedora/linux/releases/11/Everything/x86_64/os/
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to