Permalink
Browse files

Fixed problems after having converted users controller to REST

  • Loading branch information...
1 parent 122359d commit 5a26eabd001ecbdaba1b810ccaa62e80cac3c701 @spob committed Jan 12, 2011
@@ -5,7 +5,11 @@ class UsersController < ApplicationController
:import, :process_imported, :activity] => '(sysadmin | allocmgr)'
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
- verify :method => :post, :only => [:destroy, :create, :update, :update_profile, :reset_password, :process_imported, :import, :fetch_otp],
+ verify :method => :post, :only => [:create, :reset_password, :process_imported, :import, :fetch_otp],
+ :redirect_to => {:action => :index}
+ verify :method => :put, :only => [:update, :update_profile],
+ :redirect_to => {:action => :index}
+ verify :method => :delete, :only => [:destroy],
:redirect_to => {:action => :index}
def index
@@ -192,7 +196,7 @@ def activity
@user = User.find_by_email(session[:activity_email])
if @user
@topics = Topic.find(:all,
- :include => [{:forum => :slug }, :user, :slug],
+ :include => [{:forum => :slug}, :user, :slug],
:conditions => ["topics.id IN (?)", @user.topic_comments.topic_ids.collect(&:topic_id) + [-1]],
:order => "topics.created_at")
end
@@ -23,11 +23,10 @@
<p>
<%= link_to 'Request Account', new_user_request_path %>
&nbsp;|&nbsp;
- <%= link_to 'Forgot your password?', { :controller => :users,
- :action => 'lost_password' } %>
+ <%= link_to 'Forgot your password?', lost_password_users_path %>
&nbsp;|&nbsp;
<%= theme_image_tag("icons/14x14/openid-14x14.gif",
options = {:alt=>"OpenID"}) %>
<%= link_to 'Login using Open ID', { :action => 'login_openid' } %>
</p>
-</div>
+</div>
@@ -2,35 +2,36 @@
<%= set_focus_to_id 'user_first_name' %>
<%end%>
-<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
+<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
<%= error_messages_for :user %>
-<% form_for :user, :url => { :action => "update_profile", :id => @user } do |f| -%>
+<% form_for :user, :url => update_profile_user_path(@user),
+ :html => {:method => :put} do |f| -%>
<div class="formTitle">
- <%= theme_image_tag("icons/16x16/userEdit.png",
+ <%= theme_image_tag("icons/16x16/userEdit.png",
options = {:alt=>"Update Profile"}) %>Update Profile
</div>
<div class="cssform widerLabel">
- <p>
+ <p>
<label for="Email">Email:</label><%= h @user.email %>
</p>
- <p>
+ <p>
<label for="first_name">First Name:</label>
<%= f.text_field :first_name %>
</p>
- <p>
+ <p>
<label for="last_name">Last Name:</label>
<%= f.text_field :last_name %>
</p>
<p>
<label for="Open Id">Open Id:</label>
<%= f.text_field :identity_url %>
</p>
- <p>
+ <p>
<label for="time_zone">User Time Zone:</label>
<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones %>
</p>
- <p>
+ <p>
<label for="row_limit">Rows to Display:</label>
<%= f.select :row_limit, User.row_limit_options %>
</p>
@@ -52,8 +53,8 @@
html_options = {
:onmouseover => "Tip('Watch ideas for which you vote')"}, '1', '0') %>
</p>
- <p>
+ <p>
<label></label>
<%= submit_tag 'Submit', html_options = {:class=> "button", :disable_with => "Please wait..."} %> </p>
</div>
-<% end -%>
+<% end -%>
@@ -1,6 +1,6 @@
-<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
-<div id="actionButtons2">
- <%= link_to 'List Users', option = {:action => 'list'},
+<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
+<div id="actionButtons2">
+ <%= link_to 'List Users', option = {:action => 'list'},
html_options = { :class=> "button",
:onmouseover => "Tip('Return to List Users')"} %>
</div>
@@ -15,8 +15,8 @@
</ul>
Correct these errors and reimport the file.
<% end %>
-
-
+
+
<% unless @users.empty? %>
Users processed:
<p/>
@@ -35,27 +35,27 @@
<% end %>
</ul>
<% end %>
-
+
<br/>
-
+
<div id="show_images" style="<%= pix_button_display_style "SHOW" %>">
&nbsp;&nbsp;
<%= link_to_remote("Show Images",
{:url => { :action => "toggle_pix" }},
{:class => "button"} ) %>
</div>
-
+
<div id="hide_images" style="<%= pix_button_display_style "HIDE" %>">
&nbsp;&nbsp;
<%= link_to_remote("Hide Images",
{:url => { :action => "toggle_pix" }},
{:class => "button"} ) %>
</div>
-
+
<ol>
<li>
- Export the spreadsheet template.
- <%= button_to 'Export', options = { :action => "export" },
+ Export the spreadsheet template.
+ <%= button_to 'Export', options = { :action => "export" },
html_options = {:class=> "button", :method => :post }%>
</li>
<li>
@@ -68,28 +68,28 @@
<div ID="image2" style="<%= pix_display_style %>">
<%= theme_image_tag("general/users/export.png", :border=>0) %>
</div>
- Edit the contents of the file. Each new row will create a new user.
- <i>NOTE: be very careful about the values you specify in the enterprise column.
- If you enter an enterprise that is not recognized by the system, the bulk load
+ Edit the contents of the file. Each new row will create a new user.
+ <i>NOTE: be very careful about the values you specify in the enterprise column.
+ If you enter an enterprise that is not recognized by the system, the bulk load
will result in the creation of a new enterprise. Be sure this is what you intend.</i>
</li>
<li>
Save the file as a CSV file
</li>
<li>
Import the saved file.
- <% form_for :dump, :url=> {:action => "import"},
- :html => { :multipart => true } do |f| -%>
+ <% form_for :dump, :url=> import_users_path,
+ :html => { :multipart => true, :method => :post } do |f| -%>
Select a CSV File: <%= f.file_field :file -%>&nbsp;&nbsp;&nbsp;<%= submit_tag 'Import', html_options = {:class=> "button", :disable_with => "Please wait..."}-%>
<% end -%>
</li>
<li>
- When you are ready to notify users that their new accounts have been created,
+ When you are ready to notify users that their new accounts have been created,
select "Process Imported Users".
- <%= button_to 'Process Imported Users', option = {:action => 'process_imported'},
- html_options = {:class=> "button",
+ <%= button_to 'Process Imported Users', process_imported_users_path,
+ html_options = {:class=> "button",
:onmouseover => "Tip('Process user records that were imported into the users table')",
:method => :post } %>
</li>
</ol>
-</div>
+</div>
@@ -10,7 +10,7 @@
<%= button_to 'Create User', option = {:action => 'new'},
html_options = {:class=> "button",
:onmouseover => "Tip('Create a new user')"} %>
- <%= button_to 'Bulk Load', option = {:action => 'export_import'},
+ <%= button_to 'Bulk Load', export_import_users_path,
html_options = {:class=> "button",
:onmouseover => "Tip('Bulk load users into the users table')",
:method => :get } %>
View
@@ -42,7 +42,10 @@
map.resources :topics, :collection => {:preview => :get, :search => :get,
:tag => :get}, :member => {:rate => :post, :toggle_status => :put}
map.resources :users,
- :collection => {:activity => :get, :auto_complete_for_user_email => :get}
+ :member => {:update_profile => :put, :reset_password => :get},
+ :collection => {:activity => :get, :edit_profile => :get, :auto_complete_for_user_email => :get, :list => :get,
+ :process_imported => :post, :import => :get, :fetch_otp => :post, :export_import => :get,
+ :lost_password => :get}
map.resources :user_logons
map.resources :user_requests, :member => {:approve => :post, :reject => :post,
:acknowledge => :get, :next => :get, :previous => :get},
@@ -16,4 +16,4 @@
options[:dir] = default_pid_dir
end
-Daemons.run(File.dirname(__FILE__) + '/../script/task_server.rb', options)
+Daemons.run(File.dirname(__FILE__) + '/../script/task_server.rb', options)
@@ -1,7 +1,7 @@
class UsersController < ApplicationController
-
+
filter_parameter_logging :ssn
-
+
# GET /users
# GET /users.xml
def index

0 comments on commit 5a26eab

Please sign in to comment.