ref: refs/heads/master
commit ec6e6e970b691b011342d221a59d5b35c35a2d36
Author: J. Daniel Schmidt
Date: Wed Oct 7 19:15:13 2009 +0200
basic controllers and functions
---
.../app/controllers/registration_controller.rb | 19 ++++++-
plugins/registration/app/models/registration.rb | 59 +++++++++++++++++++-
.../app/views/registration/show.html.erb | 12 ++++-
.../registration/config/resources/registration.yml | 2 -
4 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/plugins/registration/app/controllers/registration_controller.rb b/plugins/registration/app/controllers/registration_controller.rb
index d610a99..e77fa7d 100644
--- a/plugins/registration/app/controllers/registration_controller.rb
+++ b/plugins/registration/app/controllers/registration_controller.rb
@@ -1,21 +1,36 @@
# = Registration controller
# Provides access to the registration of the system at NCC/SMT.
+#class Registration::RegistrationController < ApplicationController
class RegistrationController < ApplicationController
before_filter :login_required
- @@registration = Registration.new('I am a registered machine (or not)')
+
+ # @@registration = Registration.new( { :doo => :daa } )
+
def update
end
def create
# POST to registration => run registration
+ @registration = Registration.new( { } )
+ @registration.register
+ # @registration = "POST to /registration/ ... so we run the registration"
end
def show
- @registration = @@registration
+ # getRegistrationServerDetails
+ #@registration = @@registration
+ #@registration = Registration.new( getRegistrationServerDetails.to_s )
+
+ #
+ @registration = Registration.new( { } )
+ @registration.register
+ #@registration = "GET to /registration/"
end
+ def index
+ end
end
diff --git a/plugins/registration/app/models/registration.rb b/plugins/registration/app/models/registration.rb
index 1ec7ad1..133675f 100644
--- a/plugins/registration/app/models/registration.rb
+++ b/plugins/registration/app/models/registration.rb
@@ -4,14 +4,69 @@
# the caller must interpret the result and maybe call it again with
# changed values.
class Registration
+
+ require 'yast_service'
+
+ @context = { }
+ @arguments = { }
@reg = ''
- def initialize(str)
- @reg = str
+ def initialize(hash)
+ if hash.class.to_s == 'Hash'
+ @context = hash
+ else
+ raise "Invalid or missing registration initialization context data."
+ end
+ end
+
+ def set_context(hash)
+ self.initialize hash
+ end
+
+ def set_arguments(hash)
+ @arguments = hash
+ end
+
+ def add_arguments(hash)
+ @arguments.merge hash
+ end
+
+ def register
+ @reg = YastService.Call("YSR::stateless_register", @context )
end
+ def get_registration_server_details
+ @reg = "get-reg-srv-det"
+ end
+
+ def set_registration_server_details(url, ca)
+ @reg = "you want to set URL: #{ url }"
+ end
+
+
def to_xml
+ return @reg if @reg.class.to_s == String
return "<regtest>#{ @reg.to_s }</regtest>"
end
+ def to_xml( options = {} )
+ #return "This function should output XML"
+
+ xml = options[:builder] ||= Builder::XmlMarkup.new(options)
+ xml.instruct! unless options[:skip_instruct]
+
+ xml.registration do
+ xml.tag!(:info, "infotest")
+ xml.tag!(:foobar, "foobartest" )
+ xml.arguments({:type => "array"}) do
+ { "eins" => 1, "zwei" => 2, "drei" => 3 }.each do |k,v|
+ xml.argument do
+ xml.tag!( :name, k)
+ xml.tag!( :value, v)
+ end
+ end
+ end
+ end
+ end
+
end
diff --git a/plugins/registration/app/views/registration/show.html.erb b/plugins/registration/app/views/registration/show.html.erb
index e1d4cb3..6ed6334 100644
--- a/plugins/registration/app/views/registration/show.html.erb
+++ b/plugins/registration/app/views/registration/show.html.erb
@@ -1 +1,11 @@
-<%= @registration == nil ? "@registration is nil - FIXME" : @registration.to_xml -%>
+<%= # @registration == nil ? "@registration is nil - FIXME" : @registration.to_xml
+ -%>
+<%= case @registration.class.to_s
+ when 'NilClass'
+ "@registration is nil"
+ when 'String'
+ @registration.to_s
+ when 'Registration'
+ @registration.to_xml
+ end
+ -%>
diff --git a/plugins/registration/config/resources/registration.yml b/plugins/registration/config/resources/registration.yml
index 7fecfcf..4de62f9 100644
--- a/plugins/registration/config/resources/registration.yml
+++ b/plugins/registration/config/resources/registration.yml
@@ -1,5 +1,3 @@
-
interface: org.opensuse.yast.modules.yapi.registration
controller: registration
singular: true
-
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org