ref: refs/heads/use-activeresource
commit 8f70f9bfe88f951968ab82cd1e953ae87dd98c6d
Author: Jiri Suchomel
Date: Tue Sep 15 12:54:45 2009 +0200
adapt for usage in base system sequence
---
.../app/controllers/administrator_controller.rb | 15 +++++++++++++--
.../app/views/administrator/index.html.erb | 13 +++++--------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/plugins/administrator/app/controllers/administrator_controller.rb b/plugins/administrator/app/controllers/administrator_controller.rb
index 5d6ad7c..7dbef43 100644
--- a/plugins/administrator/app/controllers/administrator_controller.rb
+++ b/plugins/administrator/app/controllers/administrator_controller.rb
@@ -27,19 +27,30 @@ class AdministratorController < ApplicationController
# PUT
def update
return unless client_permissions
-
@administrator = @client.find
admin = params["administrator"]
@administrator.password = admin["password"]
@administrator.aliases = admin["aliases"]
+
+ # only save selected subset of administrator data:
+ if params.has_key? "save_aliases"
+ @administrator.password = nil
+ elsif params.has_key? "save_password"
+ @administrator.aliases = nil
+ end
+
begin
response = @administrator.save
rescue ActiveResource::ClientError => e
flash[:error] = YaST::ServiceResource.error(e)
end
- redirect_to :action => "index"
+ if params.has_key? "commit"
+ redirect_success # redirect to next step
+ else
+ redirect_to :action => "index"
+ end
end
end
diff --git a/plugins/administrator/app/views/administrator/index.html.erb b/plugins/administrator/app/views/administrator/index.html.erb
index c94cedb..4423d80 100644
--- a/plugins/administrator/app/views/administrator/index.html.erb
+++ b/plugins/administrator/app/views/administrator/index.html.erb
@@ -11,19 +11,16 @@
<tr class="bg">
<td class="first"><strong><%=_("Password")%></strong></td>
<td class="last"><%= f.password_field :password, :disabled => disabled %></td>
- <td><%= f.submit _("Save"), :disabled => disabled %></td>
+ <td><%= f.submit _("Save"), :name => "save_password", :disabled => disabled %></td>
</tr>
- <% end %>
- <% form_for(:administrator, @administrator, :url => { :action => "update" }, :html => { :method => :put } ) do |f| %>
- <%= f.error_messages %>
<tr class="bg">
<td class="first"><strong><%=_("Forward mail to")%></strong></td>
<td class="last"><%= f.text_field :aliases, :disabled => disabled %></td>
- <td><%= f.submit _("Save"), :disabled => disabled %></td>
+ <td><%= f.submit _("Save"), :name => "save_aliases", :disabled => disabled %></td>
+ </tr>
+ <tr>
+ <td><%= form_send_buttons :onclick=>"Element.show('progress')" %></td>
</tr>
<% end %>
</table>
</div>
-
-<%= link_to _('Back'), {:action => :index}, :onclick=>"Element.show('progress')", :class => "button"%>
-
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org