Add all
This commit is contained in:
parent
b35e18cd20
commit
82f55f7afe
80 changed files with 6687 additions and 5 deletions
29
lib/nulla_web/controllers/media_attachment_json.ex
Normal file
29
lib/nulla_web/controllers/media_attachment_json.ex
Normal file
|
@ -0,0 +1,29 @@
|
|||
defmodule NullaWeb.MediaAttachmentJSON do
|
||||
alias Nulla.MediaAttachments.MediaAttachment
|
||||
|
||||
@doc """
|
||||
Renders a list of media_attachments.
|
||||
"""
|
||||
def index(%{media_attachments: media_attachments}) do
|
||||
%{data: for(media_attachment <- media_attachments, do: data(media_attachment))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single media_attachment.
|
||||
"""
|
||||
def show(%{media_attachment: media_attachment}) do
|
||||
%{data: data(media_attachment)}
|
||||
end
|
||||
|
||||
defp data(%MediaAttachment{} = media_attachment) do
|
||||
%{
|
||||
id: media_attachment.id,
|
||||
type: media_attachment.type,
|
||||
mediaType: media_attachment.mediaType,
|
||||
url: media_attachment.url,
|
||||
name: media_attachment.name,
|
||||
width: media_attachment.width,
|
||||
height: media_attachment.height
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue