Class: ApplicationController

Instance Method Summary collapse

Methods included from Mumuki::Laboratory::Controllers::ActionRedirector

#redirect_after!, #save_location_before!

Methods included from Mumuki::Laboratory::Controllers::IncognitoMode

#current_incognito_user?, #current_logged_user?, #current_user, #current_user?, #incognito_mode_enabled?

Methods included from Mumuki::Laboratory::Controllers::EmbeddedMode

#embedded_mode?, #enable_embedded_rendering, #standalone_mode?

Methods included from Mumuki::Laboratory::Controllers::DynamicErrors

#bad_record, #blocked_forum, #disabled, #disabled_organization, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized, #unprepared_organization

Methods included from Mumuki::Laboratory::Controllers::Notifications

#has_notifications?, #notifications_count, #user_notifications

Methods included from Mumuki::Laboratory::Controllers::Authorization

#authorization_minimum_role, #authorization_slug, #authorize_if_private!

Methods included from Mumuki::Laboratory::Controllers::CurrentOrganization

#organization_name, #set_current_organization!, #visit_organization!

Instance Method Details

#current_immersive_organizationsObject



63
64
65
# File 'app/controllers/application_controller.rb', line 63

def current_immersive_organizations
  current_user.immersive_organizations_with_content_at(subject)
end

#current_immersive_path(context) ⇒ Object



93
94
95
# File 'app/controllers/application_controller.rb', line 93

def current_immersive_path(context)
  current_immersive_path_for context, subject&.navigable_content_in(context)
end

#current_immersive_path_for(context, content) ⇒ Object



97
98
99
100
# File 'app/controllers/application_controller.rb', line 97

def current_immersive_path_for(context, content)
  resource = content ? polymorphic_path(content) : default_immersive_path_for(context)
  context.url_for resource
end

#current_workspaceObject



89
90
91
# File 'app/controllers/application_controller.rb', line 89

def current_workspace
  Mumuki::Domain::Workspace.new(current_user, Organization.current)
end

#immersive_context_wrong?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/controllers/application_controller.rb', line 50

def immersive_context_wrong?
  current_immersive_context != Organization.current
end

#login_button(options = {}) ⇒ Object

required by Mumukit::Login



79
80
81
# File 'app/controllers/application_controller.rb', line 79

def (options = {})
  .button_html I18n.t(:sign_in), options[:class]
end

#redirect_to_proper_context!Object



54
55
56
# File 'app/controllers/application_controller.rb', line 54

def redirect_to_proper_context!
  redirect_to current_immersive_path_for(*current_immersive_context_and_content)
end

#redirect_to_usage(content) ⇒ Object

redirects to the usage in the current organization for the given content or raises a not found error if unused

Raises:

  • (Mumuki::Domain::NotFoundError)


85
86
87
# File 'app/controllers/application_controller.rb', line 85

def redirect_to_usage(content)
  raise Mumuki::Domain::NotFoundError unless content.usage_in_organization.try { |usage| redirect_to usage }
end

#should_choose_organization?Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'app/controllers/application_controller.rb', line 58

def should_choose_organization?
  return false unless current_user?
  current_immersive_organizations.multiple?
end

#validate_accessible!Object

ensures contents are accessible to current user



68
69
70
71
# File 'app/controllers/application_controller.rb', line 68

def validate_accessible!
  return if current_user&.teacher_here?
  accessible_subject&.validate_accessible_for! current_user
end

#validate_active_organization!Object



73
74
75
76
# File 'app/controllers/application_controller.rb', line 73

def validate_active_organization!
  return if current_user&.teacher_here?
  Organization.current.validate_active_for! current_user
end