mobilizon.chapril.org-mobil.../lib/mobilizon/media/picture.ex

24 lines
447 B
Elixir
Raw Normal View History

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
schema "pictures" do
embeds_one(:file, File, on_replace: :update)
2019-05-31 17:58:03 +02:00
belongs_to(:actor, Actor)
timestamps()
end
@doc false
def changeset(picture, attrs) do
picture
2019-05-31 17:58:03 +02:00
|> cast(attrs, [:actor_id])
|> cast_embed(:file)
end
end