Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Instance Method Summary (collapse)
- - (Object) autocomplete_ids
- - (Object) crop_avatar
- - (Object) destroy
- - (Object) details
- - (Object) edit_role
-
- (Object) hide_notification
GET /hide_notification/:created_at_as_id.
- - (Object) index
- - (Object) my_group_ids
- - (Object) notifications
- - (Object) show
-
- (Object) show_notification
GET /hide_notification/:created_at_as_id.
- - (Object) update_role
Methods inherited from ApplicationController
Instance Method Details
- (Object) autocomplete_ids
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/users_controller.rb', line 100 def autocomplete_ids redirect_to root_path, alert: t(:access_denied) unless current_user respond_to do |format| format.json { render :json => User.any_of({ name: /#{params[:q]}/i }, { email: /#{params[:q]}/i }) .only(:id,:name,:email) .map{ |user| [ :id => user.id.to_s, :name => user.name + " (#{user.email})" ] } .flatten } end end |
- (Object) crop_avatar
35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/users_controller.rb', line 35 def crop_avatar if !@user.new_avatar? redirect_to @user, :notice => flash[:notice] elsif is_in_crop_mode? if @user.update_attributes(params[:user]) render :show else redirect_to edit_user_path(@user), :error => @user.errors.map(&:to_s).join("<br />") end end end |
- (Object) destroy
47 48 49 50 51 |
# File 'app/controllers/users_controller.rb', line 47 def destroy @user.delete redirect_to registrations_path, :notice => t(:user_deleted) end |
- (Object) details
93 94 95 96 97 98 |
# File 'app/controllers/users_controller.rb', line 93 def details respond_to do |format| format.js format.html end end |
- (Object) edit_role
24 25 26 27 28 |
# File 'app/controllers/users_controller.rb', line 24 def edit_role if is_current_user?(@user) redirect_to registrations_path, :alert => t(:you_can_not_change_your_own_role) end end |
- (Object) hide_notification
GET /hide_notification/:created_at_as_id
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/controllers/users_controller.rb', line 72 def if user_signed_in? ts = Time.at(params[:id].to_i) notification = current_user.user_notifications.where(:created_at => ts).first unless notification.nil? notification. = true current_user.save! notice = t(:notification_successfully_hidden) error = nil else notice = nil error = t(:notification_cannot_be_hidden) end redirect_to :back, :notice => notice, :alert => error end end |
- (Object) index
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/users_controller.rb', line 8 def index @user_count = User.count @users = User.all.reject {|u| !can? :read, u }.paginate( :page => params[:page], :per_page => CONSTANTS['paginate_users_per_page']) respond_to do |format| format.js format.html end end |
- (Object) my_group_ids
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'app/controllers/users_controller.rb', line 117 def my_group_ids redirect_to root_path, alert: t(:access_denied) unless current_user respond_to do |format| format.json { render :json => current_user.user_groups .map{ |group| [ :id => group.id.to_s, :name => group.name ] } .flatten } end end |
- (Object) notifications
89 90 91 |
# File 'app/controllers/users_controller.rb', line 89 def notifications @notifications = current_user.user_notifications.unscoped.desc(:created_at) end |
- (Object) show
21 22 |
# File 'app/controllers/users_controller.rb', line 21 def show end |
- (Object) show_notification
GET /hide_notification/:created_at_as_id
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/users_controller.rb', line 54 def show_notification if user_signed_in? ts = Time.at(params[:id].to_i) notification = current_user.user_notifications.where(:created_at => ts).first unless notification.nil? notification. = false current_user.save! notice = t(:notification_successfully_shown) error = nil else notice = nil error = t(:notification_cannot_be_shown) end redirect_to :back, :notice => notice, :alert => error end end |
- (Object) update_role
30 31 32 33 |
# File 'app/controllers/users_controller.rb', line 30 def update_role @user.update_attributes!(params[:user]) redirect_to registrations_path, :notice => t(:role_of_user_updated,:user => @user.name) end |