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, #notifications_count

Methods included from Mumuki::Laboratory::Controllers::Disabling

#ensure_user_enabled!

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

#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



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

def current_immersive_organizations
  current_user.immersive_organizations_with_content_at(subject)
end

#current_immersive_path(context) ⇒ Object



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

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

#current_immersive_path_for(context, content) ⇒ Object



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

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

#current_workspaceObject



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

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

#immersive_context_wrong?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/controllers/application_controller.rb', line 46

def immersive_context_wrong?
  current_immersive_context != Organization.current
end

#login_button(options = {}) ⇒ Object

required by Mumukit::Login



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

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

#redirect_to_proper_context!Object



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

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)


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

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)


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

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

#validate_accessible!Object

ensures contents are accessible to current user



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

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

#validate_active_organization!Object



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

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