Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Constant Summary collapse
- GROUP_MESSAGING_DISABLED =
Constants set by the <form> <input> parameters transmitted using POST/PATCH/PUT requests
"0"
- GROUP_MESSAGING_ENABLED =
"1"
Instance Method Summary collapse
-
#edit ⇒ Object
GET /users/1/edit.
- #index ⇒ Object
-
#show ⇒ Object
GET /users/1.
-
#update ⇒ Object
PATCH/PUT /users/1 or /users/1.json.
Methods inherited from ApplicationController
Instance Method Details
#edit ⇒ Object
GET /users/1/edit
32 33 34 35 36 37 |
# File 'app/controllers/users_controller.rb', line 32 def edit unless can_edit? Rails.logger.warn("Unauthorized to edit user #{@user.id} (current user: #{current_user.id})") redirect_to user_path(@user) end end |
#index ⇒ Object
14 15 16 |
# File 'app/controllers/users_controller.rb', line 14 def index @users = User.all.sort_by { |user| user.family_name || "" } end |
#show ⇒ Object
GET /users/1
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/users_controller.rb', line 19 def show @search_terms = params["q"].presence @can_edit = can_edit? @my_dashboard = current_user.id == @user.id render "forbidden", status: :forbidden if !current_user.super_admin? && !@my_dashboard @unfinished_works = WorkList.unfinished_works(@user, @search_terms) @completed_works = WorkList.completed_works(@user, @search_terms) @withdrawn_works = WorkList.withdrawn_works(@user, @search_terms) @works_found = @unfinished_works.length + @completed_works.length + @withdrawn_works.length end |
#update ⇒ Object
PATCH/PUT /users/1 or /users/1.json
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/users_controller.rb', line 40 def update if can_edit? respond_to do |format| update_groups_with_messaging if user_params.key?(:groups_with_messaging) if @user.update(user_params) format.html { redirect_to user_url(@user), notice: "User was successfully updated." } format.json { render :show, status: :ok, location: @user } else # return 200 so the loadbalancer doesn't capture the error format.html { render :edit } format.json { render json: @user.errors } end end else Rails.logger.warn("Unauthorized to update user #{@user.id} (current user: #{current_user.id})") redirect_to user_path(@user) end end |