diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-09-09 19:09:24 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-09-09 19:11:06 +0400 |
commit | 2a22e8a51c436d173fd83690e283ba38c168922e (patch) | |
tree | 454dacfb4464bb247d6a19e8e90ca9b01428e517 /sonar-server/src/main | |
parent | 8645106964daa8a984053c97c7cbe6245e9279ff (diff) | |
download | sonarqube-2a22e8a51c436d173fd83690e283ba38c168922e.tar.gz sonarqube-2a22e8a51c436d173fd83690e283ba38c168922e.zip |
SONAR-2633 Add action 'change password' to users administration page
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb | 18 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb | 33 |
2 files changed, 31 insertions, 20 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb index fa7672b617f..bd04170ee35 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb @@ -32,7 +32,7 @@ class UsersController < ApplicationController if user.save flash[:notice] = 'User is created.' end - + to_index(user.errors, nil); end @@ -68,12 +68,18 @@ class UsersController < ApplicationController redirect_to(:action => 'index', :id => params[:id]) end + def change_password + @users = User.find(:all, :include => 'groups', :order => 'name') + @user = User.find(params[:id]) + render :action => 'index', :id => params[:id] + end + def update user = User.find(params[:id]) if user.login!=params[:user][:login] flash[:error] = 'Login can not be changed.' - + elsif user.update_attributes(params[:user]) flash[:notice] = 'User was successfully updated.' end @@ -100,7 +106,7 @@ class UsersController < ApplicationController def set_groups @user = User.find(params[:id]) - + if @user.set_groups(params[:groups]) flash[:notice] = 'User is updated.' end @@ -115,7 +121,7 @@ class UsersController < ApplicationController redirect_to(:action => 'index', :id => id) end - + def toggle_edit_mode() current_user.toggle_edit_mode redirect_back_or_default(:controller => 'project') @@ -129,11 +135,11 @@ class UsersController < ApplicationController user.groups<<default_group if default_group user end - + def autocomplete @users = User.find(:all, :conditions => ["UPPER(name) like ?", params[:user_name_start].clone.upcase+"%"]) @char_count = params[:user_name_start].size render :partial => 'autocomplete' end - + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb index f7ea9750355..a3856382d2b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb @@ -24,6 +24,7 @@ </td> <td class="left" valign="top"> <%= link_to "edit", { :id => user.id, :action => 'edit'}, :id => "edit-#{u user.login}" %> | + <%= link_to "change password", { :id => user.id, :action => 'change_password'}, :id => "change-password-#{u user.login}" %> | <%= link_to "delete", {:action => 'destroy', :id => user.id}, {:confirm => "Warning : are you sure to delete this user ?", :method => 'delete', :id => "delete-#{u user.login}"} %> </td> </tr> @@ -34,15 +35,18 @@ </td> <td class="sep"> </td> <td valign="top" align="right" width="210"> - <% - action_name = 'create' - title='Add new user' - if @user.id - action_name = 'update' - title='Edit user' + <% + action_name = 'create' + title = 'Add new user' + if @user.id + action_name = 'update' + title = 'Edit user' + if params[:action] == 'change_password' + title = 'Change password' end - %> - <% form_for :user, @user, :url => { :id => @user.id, :action => action_name}, :html => { :method => @user.id.nil?? :post : :put } do |f| %> + end + %> + <% form_for :user, @user, :url => { :id => @user.id, :action => action_name}, :html => { :method => @user.id.nil?? :post : :put } do |f| %> <table class="admintable" width="100%"> <tr> <td class="left" valign="top"><h1><%= title %></h1></td> @@ -52,34 +56,35 @@ <% if @user.id %> <%= @user.login %> <%= f.hidden_field :login %> - <% else %> <br/><%= f.text_field :login, :size => 30, :maxLength => 40 %> <% end %> </td> - </tr> + <% if params[:action] != 'change_password' %> <tr> <td class="left" valign="top">Name:<br/><%= f.text_field :name, :size => 30, :maxLength => 200 %></td> </tr> <tr> <td class="left" valign="top">Email:<br/><%= f.text_field :email, :size => 30, :maxLength => 100 %></td> </tr> + <% end %> + <% if params[:action] == 'change_password' || !@user.id %> <tr> <td class="left" valign="top">Password:<br/><%= f.password_field :password, :size => 30, :maxLength => 50 %></td> </tr> <tr> <td class="left" valign="top">Confirm password:<br/><%= f.password_field :password_confirmation, :size => 30, :maxLength => 50 %></td> - </tr> + </tr> + <% end %> <tr> <td class="left" nowrap="nowrap" valign="top" colspan="2"> <%= submit_tag @user.id.nil?? 'Create':'Update' %> <%= link_to 'cancel', { :controller => 'users', :action => 'index'}, { :class => 'action' } %><br/> </td> </tr> - </table> - <% end %> + <% end %> </td> </tr> -</table>
\ No newline at end of file +</table> |