2019-05-22 14:12:11 +02:00
|
|
|
defmodule Mobilizon.Media.Picture do
|
|
|
|
@moduledoc """
|
|
|
|
Represents a picture entity
|
|
|
|
"""
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
alias Mobilizon.Media.File
|
2019-05-31 17:58:03 +02:00
|
|
|
alias Mobilizon.Actors.Actor
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
schema "pictures" do
|
|
|
|
embeds_one(:file, File, on_replace: :update)
|
2019-05-31 17:58:03 +02:00
|
|
|
belongs_to(:actor, Actor)
|
2019-05-22 14:12:11 +02:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(picture, attrs) do
|
|
|
|
picture
|
2019-05-31 17:58:03 +02:00
|
|
|
|> cast(attrs, [:actor_id])
|
2019-05-22 14:12:11 +02:00
|
|
|
|> cast_embed(:file)
|
|
|
|
end
|
|
|
|
end
|