Module: Admin::ResourceHelper

Defined in:
app/helpers/admin/resource_helper.rb

Instance Method Summary collapse

Instance Method Details

#attachment_content_type(download) ⇒ Object



5
6
7
# File 'app/helpers/admin/resource_helper.rb', line 5

def attachment_content_type(download)
  t("content_type.#{download.content_type}") rescue download.content_type
end

#attachment_url(download) ⇒ Object



9
10
11
12
13
14
15
# File 'app/helpers/admin/resource_helper.rb', line 9

def attachment_url(download)
  if download.url.present?
    download.url.sub('public://', 'http://k12-content.s3-website-us-east-1.amazonaws.com/')
  else
    download.file.url
  end
end

#language_collection_optionsObject



17
18
19
# File 'app/helpers/admin/resource_helper.rb', line 17

def language_collection_options
  Language.order(:name).map { |lang| [lang.name, lang.id] }
end


26
27
28
29
30
31
32
33
34
# File 'app/helpers/admin/resource_helper.rb', line 26

def related_resource_type(resource)
  resource_types = resource.resource_types.pluck(:name)

  if resource_types.include?('video')
    t('resource_types.video')
  else
    t('resource_types.resource')
  end
end

#resource_status(resource) ⇒ Object



21
22
23
24
# File 'app/helpers/admin/resource_helper.rb', line 21

def resource_status(resource)
  status = resource.hidden? ? :hidden : :active
  t(status, scope: :resource_statuses)
end