Class: ApplicationController

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

Instance Method Summary collapse

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

#forbidden, #gone, #internal_server_error, #not_found, #unauthorized

Methods included from Mumuki::Laboratory::Controllers::Messages

#has_messages?, #messages_count

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



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

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

#redirect_to_main_organization!Object



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

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

#should_choose_organization?Boolean

Returns:

  • (Boolean)


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

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)


27
28
29
# File 'app/controllers/application_controller.rb', line 27

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
# File 'app/controllers/application_controller.rb', line 47

def validate_accessible!
  accessible_subject.validate_accessible_for!(current_user) unless (current_user? && current_user.teacher_here?)
end

#validate_used_here!Object

ensures contents are in current organization’s path



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

def validate_used_here!
  raise Mumuki::Laboratory::NotFoundError if subject && !subject.used_in?(Organization.current)
end