Skip to content
Snippets Groups Projects
Commit abd28d7d authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Merge branch 'default-attachment-location' into 'master'

added default attachment location to LO serializer

See merge request !406
parents 9cd70996 df7d4529
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,11 @@ class LearningObject < ApplicationRecord ...@@ -109,6 +109,11 @@ class LearningObject < ApplicationRecord
nil nil
end end
# If a LO has more than one object, this gives the location of the main one
def default_attachment_location
object_type.try(:name) == ("Vídeo" || "Áudio") ? default_attachment.try(:retrieve_cache_link) : default_attachment.try(:retrieve_url)
end
def default_thumbnail def default_thumbnail
return thumbnail unless thumbnail.blank? return thumbnail unless thumbnail.blank?
return nil if attachments.blank? return nil if attachments.blank?
...@@ -125,8 +130,9 @@ class LearningObject < ApplicationRecord ...@@ -125,8 +130,9 @@ class LearningObject < ApplicationRecord
default_attachment.retrieve_cache_link default_attachment.retrieve_cache_link
end end
# Download link with all relevant objects (currently only one)
def download_link def download_link
object_type.try(:name) == ("Vídeo" || "Áudio") ? default_attachment.try(:retrieve_cache_link) : default_attachment.try(:retrieve_url) default_attachment_location
end end
## score methods ## score methods
......
...@@ -37,6 +37,7 @@ class LearningObjectSerializer < ActiveModel::Serializer ...@@ -37,6 +37,7 @@ class LearningObjectSerializer < ActiveModel::Serializer
:thumbnail, :thumbnail,
:object_type, :object_type,
:language, :language,
:default_attachment_location,
:default_attachment_id, :default_attachment_id,
:default_mime_type, :default_mime_type,
:score, :score,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment