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::Disabling

#ensure_user_enabled!

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



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

def current_immersive_organizations
  current_user.immersive_organizations_with_content_at(subject)
end

#current_immersive_path(context) ⇒ Object



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

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

#current_immersive_path_for(context, content) ⇒ Object



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

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

#current_workspaceObject



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

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

#immersive_context_wrong?Boolean

Returns:

  • (Boolean)


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

def immersive_context_wrong?
  current_immersive_context != Organization.current
end

#login_button(options = {}) ⇒ Object

required by Mumukit::Login



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

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

#redirect_to_proper_context!Object



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

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)


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

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)


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

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

#validate_accessible!Object

ensures contents are accessible to current user



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

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

#validate_active_organization!Object



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

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