Class: UsersController
Instance Method Summary
collapse
#user_name_params, #user_params
#current_immersive_organizations, #current_immersive_path, #current_immersive_path_for, #current_workspace, #immersive_context_wrong?, #login_button, #redirect_to_proper_context!, #redirect_to_usage, #should_choose_organization?, #validate_accessible!, #validate_active_organization!
#redirect_after!, #save_location_before!
#current_incognito_user?, #current_logged_user?, #current_user, #current_user?, #incognito_mode_enabled?
#embedded_mode?, #enable_embedded_rendering, #standalone_mode?
#bad_record, #blocked_forum, #disabled, #disabled_organization, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized, #unprepared_organization
#has_notifications?, #notifications_count, #user_notifications
#authorization_slug, #authorize_if_private!
#organization_name, #set_current_organization!, #visit_organization!
Instance Method Details
#accept_profile_terms ⇒ Object
17
18
19
20
21
|
# File 'app/controllers/users_controller.rb', line 17
def accept_profile_terms
current_user.accept_profile_terms!
flash.notice = I18n.t(:terms_accepted)
redirect_after! :terms_acceptance, fallback_location: root_path
end
|
#activity ⇒ Object
38
39
40
|
# File 'app/controllers/users_controller.rb', line 38
def activity
@activity = UserStats.stats_for(current_user).activity date_range_params
end
|
#certificates ⇒ Object
42
43
44
|
# File 'app/controllers/users_controller.rb', line 42
def certificates
@certificates ||= current_user.certificates_in_organization
end
|
#delete_confirmation ⇒ Object
56
57
58
59
60
61
62
|
# File 'app/controllers/users_controller.rb', line 56
def delete_confirmation
return redirect_to delete_confirmation_invalid_user_path unless @user.delete_account_token_matches? params[:token]
@user.destroy!
redirect_to logout_path, notice: I18n.t(:user_deleted_successfully)
end
|
#discussions ⇒ Object
31
32
33
34
35
36
|
# File 'app/controllers/users_controller.rb', line 31
def discussions
@watched_discussions = current_user.watched_discussions_in_organization
.where(exercise: Organization.current.exercises)
.scoped_query_by(discussion_filter_params)
.unread_first
end
|
#exam_authorizations ⇒ Object
46
47
48
|
# File 'app/controllers/users_controller.rb', line 46
def exam_authorizations
@exam_authorization_requests ||= ExamAuthorizationRequest.where(user: current_user, organization: Organization.current)
end
|
#manage_notifications ⇒ Object
81
82
83
84
85
|
# File 'app/controllers/users_controller.rb', line 81
def manage_notifications
@user.update! ignored_notifications: manage_notifications_params.reject { |_, allowed| allowed.to_boolean }.keys
redirect_to notifications_user_path, notice: I18n.t(:preferences_updated_successfully)
end
|
#messages ⇒ Object
27
28
29
|
# File 'app/controllers/users_controller.rb', line 27
def messages
@messages ||= current_user.messages_in_organization
end
|
#notifications ⇒ Object
68
69
70
|
# File 'app/controllers/users_controller.rb', line 68
def notifications
@notifications = @user.notifications_in_organization.order(created_at: :desc).page(params[:page])
end
|
#permissible_params ⇒ Object
64
65
66
|
# File 'app/controllers/users_controller.rb', line 64
def permissible_params
super << [:avatar_id, :avatar_type]
end
|
#send_delete_confirmation_email ⇒ Object
50
51
52
53
54
|
# File 'app/controllers/users_controller.rb', line 50
def send_delete_confirmation_email
current_user.generate_delete_account_token!
UserMailer.delete_account(current_user).post!
redirect_to delete_request_user_path
end
|
#show_manage_notifications ⇒ Object
77
78
79
|
# File 'app/controllers/users_controller.rb', line 77
def show_manage_notifications
render 'manage_notifications'
end
|
#terms ⇒ Object
23
24
25
|
# File 'app/controllers/users_controller.rb', line 23
def terms
@profile_terms ||= Term.profile_terms_for(current_user)
end
|
#toggle_read ⇒ Object
72
73
74
75
|
# File 'app/controllers/users_controller.rb', line 72
def toggle_read
@notification.toggle! :read
redirect_to notifications_user_path
end
|
#update ⇒ Object
10
11
12
13
14
15
|
# File 'app/controllers/users_controller.rb', line 10
def update
current_user.update_and_notify! user_params
current_user.accept_profile_terms!
flash.notice = I18n.t(:user_data_updated)
redirect_after! :profile_completion, fallback_location: user_path
end
|