ref: refs/heads/master
commit 9174705cec14b6cec37b8cbdde601fe7cb4fa20a
Author: Jiri Suchomel
Date: Wed Aug 5 11:56:36 2009 +0200
back to ror conventions
removed ssh key handling (for now)
---
plugins/users/app/controllers/users_controller.rb | 85 ++++++---------------
plugins/users/app/views/users/edit.html.erb | 8 +-
plugins/users/app/views/users/exportssh.html.erb | 25 ------
plugins/users/app/views/users/index.html.erb | 2 +-
plugins/users/app/views/users/new.html.erb | 8 +-
5 files changed, 32 insertions(+), 96 deletions(-)
diff --git a/plugins/users/app/controllers/users_controller.rb b/plugins/users/app/controllers/users_controller.rb
index d719856..08d72fd 100644
--- a/plugins/users/app/controllers/users_controller.rb
+++ b/plugins/users/app/controllers/users_controller.rb
@@ -53,13 +53,12 @@ class UsersController < ApplicationController
:groupname => nil,
:cn => nil,
:grouplist => {},
- :homeDirectory => nil,
+ :home_directory => nil,
:cn => nil,
:uid => nil,
- :uidNumber => nil,
- :sshkey => nil,
- :loginShell => "/bin/bash",
- :userPassword => nil,
+ :uid_number => nil,
+ :login_shell => "/bin/bash",
+ :user_password => nil,
:type => "local",
:id => nil
)
@@ -70,18 +69,6 @@ class UsersController < ApplicationController
end
end
- # GET /users/1/exportssh
- def exportssh
- return unless client_permissions
- @user = @client.find(params[:id])
- @user.type = ""
- @user.id = @user.uid
- logger.debug "exportssh: #{@user.inspect}"
- respond_to do |format|
- format.html # exportssh.html.erb
- format.xml { render :xml => @user, :location => "none" }
- end
- end
# GET /users/1/edit
def edit
@@ -95,10 +82,10 @@ class UsersController < ApplicationController
# FIXME hack, this must be done properly
# (my keys in camelCase were transformed to under_scored)
- @user.uidNumber = @user.uid_number
- @user.homeDirectory = @user.home_directory
- @user.loginShell = @user.login_shell
- @user.userPassword = @user.user_password
+ @user.uid_number = @user.uid_number
+ @user.home_directory = @user.home_directory
+ @user.login_shell = @user.login_shell
+ @user.user_password = @user.user_password
counter = 0
@user.grouplist.each do |group|
@@ -111,33 +98,6 @@ class UsersController < ApplicationController
end
end
- # POST /users/1/sshexport
- def sshexport
- return unless client_permissions
-
- @user = @client.find(params["user"]["uid"])
- @user.id = @user.uid
- logger.debug "sshexportssh: #{@user.inspect}"
- @user.sshkey = params["user"]["sshkey"]
- response = true
- begin
- response = @user.save
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- response = false
- end
- logger.debug "sshexportssh: #{response}"
- respond_to do |format|
- if response
- flash[:notice] = _('SSH-Key was successfully exported.')
- format.html { redirect_to(users_url) }
- else
- format.html { render :action => "exportssh" }
- format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
- end
- end
- end
-
# POST /users
# POST /users.xml
@@ -146,29 +106,30 @@ class UsersController < ApplicationController
dummy = @client.new(params[:user])
dummy.grp_string = params[:user][:grp_string] #do not know, why this will not be assigned in the constructor
- dummy.groups = []
+ dummy.grouplist = {}
if dummy.grp_string != nil
dummy.grp_string.split(",").each do |group|
- dummy.groups << { :id=>group.strip }
+ dummy.grouplist[group.strip] = 1
end
end
+
@user = @client.new(
:groupname => dummy.groupname,
:uid => dummy.uid,
:grouplist => dummy.grouplist,
-# :grp_string=>dummy.grp_string,
- :homeDirectory => dummy.homeDirectory,
+ :home_directory => dummy.home_directory,
:cn => dummy.cn,
- :uidNumber => dummy.uidNumber,
- :sshkey => nil,
- :loginShell => dummy.loginShell,
- :userPassword => dummy.userPassword,
+ :uid_number => dummy.uid_number,
+ :login_shell => dummy.login_shell,
+ :user_password => dummy.user_password,
:type => "local"
)
+ @user.grp_string = dummy.grp_string
#Only UID greater than 1000 are allowed for local user
+ # FIXME leave this check on YaPI?
response = true
- if @user.uidNumber.to_i < 1000
+ if @user.uid_number.to_i < 1000
response = false
else
begin
@@ -183,7 +144,7 @@ class UsersController < ApplicationController
flash[:notice] = _('User was successfully created.')
format.html { redirect_to(users_url) }
else
- if @user.uidNumber.to_i < 1000
+ if @user.uid_number.to_i < 1000
#Only UID greater than 1000 are allowed for local user
flash[:error] = _("UID: value >= 1000 is valid for local user only")
end
@@ -214,11 +175,11 @@ class UsersController < ApplicationController
# if @user.uid != params["user"]["uid"]
# @user.new_uid = params["user"]["uid"]
# end
- @user.uidNumber = params["user"]["uidNumber"]
- @user.homeDirectory = params["user"]["homeDirectory"]
+ @user.uid_number = params["user"]["uid_number"]
+ @user.home_directory = params["user"]["home_directory"]
@user.cn = params["user"]["cn"]
- @user.loginShell = params["user"]["loginShell"]
- @user.userPassword = params["user"]["userPassword"]
+ @user.login_shell = params["user"]["login_shell"]
+ @user.user_password = params["user"]["user_password"]
@user.type = "local"
respond_to do |format|
diff --git a/plugins/users/app/views/users/edit.html.erb b/plugins/users/app/views/users/edit.html.erb
index 1d186ac..cc36b1a 100644
--- a/plugins/users/app/views/users/edit.html.erb
+++ b/plugins/users/app/views/users/edit.html.erb
@@ -25,11 +25,11 @@
</tr>
<tr class="bg">
<td class="first"><strong><%=_("Home Directory")%></strong></td>
- <td class="last"><%= f.text_field :homeDirectory, :disabled => disabled %></td>
+ <td class="last"><%= f.text_field :home_directory, :disabled => disabled %></td>
</tr>
<tr>
<td class="first"><strong><%=_("Login Shell")%></strong></td>
- <td class="last"><%= f.text_field :loginShell, :disabled => disabled %></td>
+ <td class="last"><%= f.text_field :login_shell, :disabled => disabled %></td>
</tr>
<tr class="bg">
<td class="first"><strong><%=_("Login Name")%></strong></td>
@@ -37,11 +37,11 @@
</tr>
<tr>
<td class="first"><strong><%=_("UID Number")%></strong></td>
- <td class="last"><%= f.text_field :uidNumber , :disabled => disabled %></td>
+ <td class="last"><%= f.text_field :uid_number , :disabled => disabled %></td>
</tr>
<tr class="bg">
<td class="first"><strong><%=_("Password")%></strong></td>
- <td class="last"><%= f.text_field :userPassword, :disabled => disabled %></td>
+ <td class="last"><%= f.text_field :user_password, :disabled => disabled %></td>
</tr>
</table>
<p><%= f.submit _("Update"), :disabled => disabled %><%= link_to _('Back'), users_path, :onclick=>"Element.show('progress')", :class => "button"%></p>
diff --git a/plugins/users/app/views/users/exportssh.html.erb b/plugins/users/app/views/users/exportssh.html.erb
deleted file mode 100644
index af773a6..0000000
--- a/plugins/users/app/views/users/exportssh.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<h1><%=_("Export SSH-Key")%></h1>
-<% form_for(:user, @user, :url => { :action => "sshexport" }, :html => { :method => :post }) do |f| %>
- <%= f.error_messages %>
-
- <div class="table">
- <table class="listing form" cellpadding="0" cellspacing="0">
- <tr>
- <th class="full" colspan="2"><%=_("User")%></th>
- </tr>
- <tr class="bg">
- <td class="first"><strong><%=_("Login Name")%></strong></td>
- <td class="last"><%= f.text_field :uid, :disabled => false %></td>
- </tr>
- <tr class="bg">
- <td class="first"><strong><%=_("Home Directory")%></strong></td>
- <td class="last"><%=h @user.homeDirectory %></td>
- </tr>
- <tr>
- <td class="first"><strong><%=_("SHH Key")%></strong></td>
- <td class="last"><%= f.text_field :sshkey, :disabled=>!@permissions[:usermodify] %></td>
- </tr>
- </table>
- <p><%= f.submit _("Export SSH-Key"), :commit=>"Export SSH-Key", :onclick=>"Element.show('progress')", :disabled=>!@permissions[:usermodify] %><%= link_to _('Back'), users_path, :onclick=>"Element.show('progress')", :class => "button" %></p>
- </div>
-<% end %>
diff --git a/plugins/users/app/views/users/index.html.erb b/plugins/users/app/views/users/index.html.erb
index 912ccad..f4a3798 100644
--- a/plugins/users/app/views/users/index.html.erb
+++ b/plugins/users/app/views/users/index.html.erb
@@ -18,7 +18,7 @@
<td><%=h user.cn %></td>
<td><%= link_to image_tag("/images/edit-icon.gif", :alt => :edit), {:action => :edit, :id => user.id}, :onclick=>"Element.show('progress')" %></td>
<% if @permissions[:userdelete] %>
- <td class="last"><%= html_delete_link(user.uid) %></td>
+ <td class="last"><%= html_delete_link(user.uid, :destroy) %></td>
<% end %>
</tr>
<% end %>
diff --git a/plugins/users/app/views/users/new.html.erb b/plugins/users/app/views/users/new.html.erb
index d443fde..3844eb1 100644
--- a/plugins/users/app/views/users/new.html.erb
+++ b/plugins/users/app/views/users/new.html.erb
@@ -19,7 +19,7 @@
</tr>
<tr class="bg">
<td class="first"><strong><%=_("Home Directory")%></strong></td>
- <td class="last"><%= f.text_field :homeDirectory %></td>
+ <td class="last"><%= f.text_field :home_directory %></td>
</tr>
<tr>
<td class="first"><strong><%=_("do NOT create home directory")%></strong></td>
@@ -27,7 +27,7 @@
</tr>
<tr class="bg">
<td class="first"><strong><%=_("Login Shell")%></strong></td>
- <td class="last"><%= f.text_field :loginShell %></td>
+ <td class="last"><%= f.text_field :login_shell %></td>
</tr>
<tr>
<td class="first"><strong><%=_("Login Name")%></strong></td>
@@ -35,11 +35,11 @@
</tr>
<tr class="bg">
<td class="first"><strong><%=_("UID Number")%></strong></td>
- <td class="last"><%= f.text_field :uidNumber %></td>
+ <td class="last"><%= f.text_field :uid_number %></td>
</tr>
<tr>
<td class="first"><strong><%=_("Password")%></strong></td>
- <td class="last"><%= f.text_field :userPassword %></td>
+ <td class="last"><%= f.text_field :user_password %></td>
</tr>
</table>
<p><%= f.submit _("Create"), :onclick=>"Element.show('progress')" %><%= link_to _('Back'), users_path, :onclick=>"Element.show('progress')", :class => "button" %></p>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org