Class: WelcomeController

Inherits:
ApplicationController show all
Defined in:
app/controllers/welcome_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #require_admin_user

Instance Method Details

#dash_adminObject



47
48
49
50
51
52
# File 'app/controllers/welcome_controller.rb', line 47

def dash_admin
  return if current_user.nil? || current_user.id.nil?
  if params.key?("dashtab")
    session[:dashtab] = params[:dashtab]
  end
end

#dash_classicObject



33
34
35
36
37
38
# File 'app/controllers/welcome_controller.rb', line 33

def dash_classic
  return if current_user.nil? || current_user.id.nil?
  if params.key?("dashtab")
    session[:dashtab] = params[:dashtab]
  end
end

#dash_projectObject



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

def dash_project
  return if current_user.nil? || current_user.id.nil?
  if params.key?("dashtab")
    session[:dashtab] = params[:dashtab]
  end
end

#emulateObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/welcome_controller.rb', line 21

def emulate
  return if Rails.env.production?
  return if current_user.nil? || current_user.id.nil?

  absolute_user = User.find(current_user.id)
  return unless absolute_user.trainer

  if params.key?("emulation_menu")
    session[:emulation_role] = params[:emulation_menu]
  end
end

#helpObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/welcome_controller.rb', line 54

def help
  # Piggybacking on this page to pass custom HTTP headers to Mediaflux
  # in a very controlled scenario.
  root_ns = Rails.configuration.mediaflux["api_root_collection_namespace"]
  parent_collection = Rails.configuration.mediaflux["api_root_collection_name"]
  @test_path = Pathname.new(root_ns).join(parent_collection)
  @test_http_headers = false
  unless current_user.nil?
    @test_http_headers = params["http-headers"] == "true"
    request = if @test_http_headers
                Mediaflux::AssetExistRequest.new(session_token: current_user.mediaflux_session, path: @test_path, session_user: current_user)
              else
                Mediaflux::AssetExistRequest.new(session_token: current_user.mediaflux_session, path: @test_path)
              end
    @test_path_exist = request.exist?
  end
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/welcome_controller.rb', line 6

def index
  return if current_user.nil?
  @pending_projects = Project.pending_projects.map { |project| ProjectDashboardPresenter.new(project) }
  @approved_projects = Project.approved_projects.map { |project| ProjectDashboardPresenter.new(project) }
  @eligible_data_user = true if !current_user.eligible_sponsor? && !current_user.eligible_manager?

  @dashboard_projects = Project.users_projects(@current_user).map { |project| ProjectDashboardPresenter.new(project) }

  @my_inventory_requests = current_user.user_requests.where(type: "FileInventoryRequest")
  @dash_session = "project"
  session[:dashtab] ||= @dash_session
  @dash_session = session[:dashtab]
  @session_id = current_user.mediaflux_session
end