Class: ProjectDashboardPresenter

Inherits:
ProjectShowPresenter show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
app/presenters/project_dashboard_presenter.rb

Instance Attribute Summary

Attributes inherited from ProjectShowPresenter

#project, #project_metadata

Instance Method Summary collapse

Methods inherited from ProjectShowPresenter

#created, #data_manager, #data_sponsor, #formatted_quota_percentage, #formatted_storage_capacity, #initialize, #project_directory, #quota_percentage, #quota_usage, #storage_capacity, #storage_usage, #to_xml, #updated, #xml_document, xml_presenter_class

Constructor Details

This class inherits a constructor from ProjectShowPresenter

Instance Method Details

#last_activityObject



28
29
30
31
32
33
34
# File 'app/presenters/project_dashboard_presenter.rb', line 28

def last_activity
  if .updated_on.nil?
    "Not yet active"
  else
    "#{remove_about time_ago_in_words(.updated_on)} ago"
  end
end

#latest_file_list_timeObject



17
18
19
20
21
22
23
24
25
26
# File 'app/presenters/project_dashboard_presenter.rb', line 17

def latest_file_list_time
  requests = FileInventoryRequest.where(project_id: project.id).order(completion_time: :desc)
  if requests.empty?
    "No Downloads"
  elsif requests.first.completion_time
    "Prepared #{time_ago_in_words(requests.first.completion_time)} ago"
  else
    "Preparing now"
  end
end

#remove_about(time_ago) ⇒ Object

Removes “about” (as in “about 1 month ago”) from time_ago_in_words



47
48
49
# File 'app/presenters/project_dashboard_presenter.rb', line 47

def remove_about(time_ago)
  time_ago.gsub("about ", "")
end

#role(user) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'app/presenters/project_dashboard_presenter.rb', line 36

def role(user)
  if data_sponsor == user.uid
    "Sponsor"
  elsif data_manager == user.uid
    "Data Manager"
  else
    "Data User"
  end
end

#typeObject



9
10
11
12
13
14
15
# File 'app/presenters/project_dashboard_presenter.rb', line 9

def type
  if storage_performance_expectations["approved"].nil?
    "Requested #{storage_performance_expectations['requested']}"
  else
    storage_performance_expectations["approved"]
  end
end