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
#ensure_user_enabled!
#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
|
#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
74
75
76
77
78
|
# File 'app/controllers/users_controller.rb', line 74
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
61
62
63
|
# File 'app/controllers/users_controller.rb', line 61
def notifications
@notifications = @user.notifications_in_organization.order(created_at: :desc).page(params[:page])
end
|
#permissible_params ⇒ Object
57
58
59
|
# File 'app/controllers/users_controller.rb', line 57
def permissible_params
super << [:avatar_id, :avatar_type]
end
|
#show_manage_notifications ⇒ Object
70
71
72
|
# File 'app/controllers/users_controller.rb', line 70
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
65
66
67
68
|
# File 'app/controllers/users_controller.rb', line 65
def toggle_read
@notification.toggle! :read
redirect_to notifications_user_path
end
|
#unsubscribe ⇒ Object
50
51
52
53
54
55
|
# File 'app/controllers/users_controller.rb', line 50
def unsubscribe
user_id = User.unsubscription_verifier.verify(params[:id])
User.find(user_id).unsubscribe_from_reminders!
redirect_to root_path, notice: t(:unsubscribed_successfully)
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
|