summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-30 18:22:46 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-30 18:22:46 +0000
commit86ba692bf5312b37b6e30778d14daf0a675254bb (patch)
tree6e1f42db58dc520e33c1e464c88840d627b3772f /app
parentd06a1a7fa47a2c3b02e9d97034e6acaf2dc5a01d (diff)
downloadredmine-86ba692bf5312b37b6e30778d14daf0a675254bb.tar.gz
redmine-86ba692bf5312b37b6e30778d14daf0a675254bb.zip
Refactor: split UsersController#edit into #edit and #update
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4230 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb69
-rw-r--r--app/helpers/users_helper.rb8
-rw-r--r--app/views/users/_general.rhtml2
-rw-r--r--app/views/users/_groups.rhtml2
4 files changed, 46 insertions, 35 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 1fd8347b7..66979d5e2 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -116,40 +116,51 @@ class UsersController < ApplicationController
@notification_options = @user.valid_notification_options
@notification_option = @user.mail_notification
- if request.post?
- @user.admin = params[:user][:admin] if params[:user][:admin]
- @user.login = params[:user][:login] if params[:user][:login]
- if params[:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
- @user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
- end
- @user.group_ids = params[:user][:group_ids] if params[:user][:group_ids]
- @user.attributes = params[:user]
- # Was the account actived ? (do it before User#save clears the change)
- was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
- # TODO: Similar to My#account
- @user.mail_notification = params[:notification_option] || 'only_my_events'
- @user.pref.attributes = params[:pref]
- @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
-
- if @user.save
- @user.pref.save
- @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
-
- if was_activated
- Mailer.deliver_account_activated(@user)
- elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
- Mailer.deliver_account_information(@user, params[:password])
- end
- flash[:notice] = l(:notice_successful_update)
- redirect_to :back
- end
- end
@auth_sources = AuthSource.find(:all)
@membership ||= Member.new
+ end
+
+ verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
+ def update
+ @user = User.find(params[:id])
+ @notification_options = @user.valid_notification_options
+ @notification_option = @user.mail_notification
+
+ @user.admin = params[:user][:admin] if params[:user][:admin]
+ @user.login = params[:user][:login] if params[:user][:login]
+ if params[:password].present? && (@user.auth_source_id.nil? || params[:user][:auth_source_id].blank?)
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
+ end
+ @user.group_ids = params[:user][:group_ids] if params[:user][:group_ids]
+ @user.attributes = params[:user]
+ # Was the account actived ? (do it before User#save clears the change)
+ was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
+ # TODO: Similar to My#account
+ @user.mail_notification = params[:notification_option] || 'only_my_events'
+ @user.pref.attributes = params[:pref]
+ @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
+
+ if @user.save
+ @user.pref.save
+ @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
+
+ if was_activated
+ Mailer.deliver_account_activated(@user)
+ elsif @user.active? && params[:send_information] && !params[:password].blank? && @user.auth_source_id.nil?
+ Mailer.deliver_account_information(@user, params[:password])
+ end
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to :back
+ else
+ @auth_sources = AuthSource.find(:all)
+ @membership ||= Member.new
+
+ render :action => :edit
+ end
rescue ::ActionController::RedirectBackError
redirect_to :controller => 'users', :action => 'edit', :id => @user
end
-
+
def edit_membership
@user = User.find(params[:id])
@membership = Member.edit_membership(params[:membership_id], params[:membership], @user)
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 757a91a9f..37cecc05c 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -34,14 +34,14 @@ module UsersHelper
end
def change_status_link(user)
- url = {:controller => 'users', :action => 'edit', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
+ url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
if user.locked?
- link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
+ link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
elsif user.registered?
- link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
+ link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
elsif user != User.current
- link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
+ link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock'
end
end
diff --git a/app/views/users/_general.rhtml b/app/views/users/_general.rhtml
index e962056a2..a08b3cee3 100644
--- a/app/views/users/_general.rhtml
+++ b/app/views/users/_general.rhtml
@@ -1,4 +1,4 @@
-<% labelled_tabular_form_for :user, @user, :url => { :controller => 'users', :action => "edit", :tab => nil }, :html => { :class => nil } do |f| %>
+<% labelled_tabular_form_for :user, @user, :url => { :controller => 'users', :action => "update", :tab => nil }, :html => { :method => :put, :class => nil } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<% if @user.active? -%>
<p><label><%= check_box_tag 'send_information', 1, true %> <%= l(:label_send_information) %></label>
diff --git a/app/views/users/_groups.rhtml b/app/views/users/_groups.rhtml
index 4bca77c00..0ab2f11eb 100644
--- a/app/views/users/_groups.rhtml
+++ b/app/views/users/_groups.rhtml
@@ -1,4 +1,4 @@
-<% form_for(:user, :url => { :action => 'edit' }) do %>
+<% form_for(:user, :url => { :action => 'update' }, :html => {:method => :put}) do %>
<div class="box">
<% Group.all.sort.each do |group| %>
<label><%= check_box_tag 'user[group_ids][]', group.id, @user.groups.include?(group) %> <%=h group %></label><br />