ref: refs/heads/network
commit 1ad93e91d65f84512cb38d67e0cc4835e15f5610
Author: Josef Reidinger
Date: Thu Aug 20 10:51:09 2009 +0200
doen't use views for oneliner function
---
.../time/app/controllers/systemtimes_controller.rb | 14 ++++++++------
plugins/time/app/models/systemtime.rb | 9 +++++++++
plugins/time/app/views/systemtimes/show.html.erb | 1 -
plugins/time/app/views/systemtimes/show.json.erb | 1 -
plugins/time/app/views/systemtimes/show.xml.erb | 1 -
5 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/plugins/time/app/controllers/systemtimes_controller.rb b/plugins/time/app/controllers/systemtimes_controller.rb
index 2bc0d6a..c49a91c 100644
--- a/plugins/time/app/controllers/systemtimes_controller.rb
+++ b/plugins/time/app/controllers/systemtimes_controller.rb
@@ -24,13 +24,9 @@ class SystemtimesController < ApplicationController
render ErrorResult.error(404, 2, "format or internal error") and return
end
- @systemtime = Systemtime.new
- @systemtime.time = root[:time]
- @systemtime.date = root[:date]
- @systemtime.timezone = root[:timezone]
- @systemtime.utcstatus = root[:utcstatus]
+ @systemtime = Systemtime.create_from_xml(root)
@systemtime.save
- render :show
+ show
end
# See update
@@ -47,6 +43,12 @@ class SystemtimesController < ApplicationController
@systemtime = Systemtime.find
+ respond_to do |format|
+ format.html { @systemtime.to_xml( :root => "systemtime", :dasherize => false ) }
+ format.xml { @systemtime.to_xml( :root => "systemtime", :dasherize => false ) }
+ format.json { @systemtime.to_json( :root => "systemtime", :dasherize => false ) }
+ end
+
end
end
diff --git a/plugins/time/app/models/systemtime.rb b/plugins/time/app/models/systemtime.rb
index b402f30..9a97a20 100644
--- a/plugins/time/app/models/systemtime.rb
+++ b/plugins/time/app/models/systemtime.rb
@@ -52,6 +52,15 @@ class Systemtime
return @@timezones
end
+ def Systemtime.create_from_xml(xmlroot)
+ systemtime = Systemtime.new
+ systemtime.time = xmlroot[:time]
+ systemtime.date = xmlroot[:date]
+ systemtime.timezone = xmlroot[:timezone]
+ systemtime.utcstatus = xmlroot[:utcstatus]
+ return systemtime
+ end
+
def initialize
end
diff --git a/plugins/time/app/views/systemtimes/show.html.erb b/plugins/time/app/views/systemtimes/show.html.erb
deleted file mode 100644
index 75edc33..0000000
--- a/plugins/time/app/views/systemtimes/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= @systemtime.to_xml( :root => "systemtime", :dasherize => false ) -%>
\ No newline at end of file
diff --git a/plugins/time/app/views/systemtimes/show.json.erb b/plugins/time/app/views/systemtimes/show.json.erb
deleted file mode 100644
index a3f0ee5..0000000
--- a/plugins/time/app/views/systemtimes/show.json.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= @systemtime.to_json( :root => "systemtime", :dasherize => false ) -%>
\ No newline at end of file
diff --git a/plugins/time/app/views/systemtimes/show.xml.erb b/plugins/time/app/views/systemtimes/show.xml.erb
deleted file mode 100644
index 75edc33..0000000
--- a/plugins/time/app/views/systemtimes/show.xml.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= @systemtime.to_xml( :root => "systemtime", :dasherize => false ) -%>
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org