Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Mumuki::Laboratory::Controllers::Authorization, Mumuki::Laboratory::Controllers::CurrentOrganization, Mumuki::Laboratory::Controllers::DynamicErrors, Mumuki::Laboratory::Controllers::EmbeddedMode, Mumuki::Laboratory::Controllers::Notifications, Mumukit::Login::AuthenticationHelpers
Defined in:
app/controllers/application_controller.rb

Instance Method Summary collapse

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, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized

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

#has_notifications?, #notifications_count, #user_notifications_path

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

#authorization_slug, #authorize_if_private!, #from_sessions?

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

#organization_name, #set_current_organization!, #visit_organization!

Instance Method Details

#login_button(options = {}) ⇒ Object

required by Mumukit::Login



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

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

#redirect_to_main_organization!Object



36
37
38
# File 'app/controllers/application_controller.rb', line 36

def redirect_to_main_organization!
  redirect_to current_user.main_organization.url_for(request.path)
end

#should_choose_organization?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
# File 'app/controllers/application_controller.rb', line 40

def should_choose_organization?
  current_user? &&
    current_user.has_accessible_organizations? &&
    Mumukit::Platform.implicit_organization?(request)
end

#should_redirect_to_main_organization?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/controllers/application_controller.rb', line 32

def should_redirect_to_main_organization?
  should_choose_organization? && current_user.has_immersive_main_organization?
end

#validate_accessible!Object

ensures contents are accessible to current user



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

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