]> git.openstreetmap.org Git - rails.git/blob - app/controllers/users/statuses_controller.rb
Merge remote-tracking branch 'upstream/pull/5520'
[rails.git] / app / controllers / users / statuses_controller.rb
1 module Users
2   class StatusesController < ApplicationController
3     layout "site"
4
5     before_action :authorize_web
6     before_action :set_locale
7     before_action :check_database_readable
8
9     authorize_resource :class => :user_status
10
11     before_action :lookup_user_by_name
12
13     ##
14     # sets a user's status
15     def update
16       @user.activate! if params[:event] == "activate"
17       @user.confirm! if params[:event] == "confirm"
18       @user.unconfirm! if params[:event] == "unconfirm"
19       @user.hide! if params[:event] == "hide"
20       @user.unhide! if params[:event] == "unhide"
21       @user.unsuspend! if params[:event] == "unsuspend"
22       @user.soft_destroy! if params[:event] == "soft_destroy" # destroy a user, marking them as deleted and removing personal data
23       redirect_to user_path(params[:user_display_name])
24     end
25
26     private
27
28     ##
29     # ensure that there is a "user" instance variable
30     def lookup_user_by_name
31       @user = User.find_by!(:display_name => params[:user_display_name])
32     rescue ActiveRecord::RecordNotFound
33       redirect_to user_path(params[:user_display_name]) unless @user
34     end
35   end
36 end