2018-05-18 09:56:21 +02:00
|
|
|
defmodule Eventos.Actors.Member do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
2018-05-18 09:56:21 +02:00
|
|
|
Represents the membership of an actor to a group
|
2018-01-14 17:56:50 +01:00
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
2018-05-18 09:56:21 +02:00
|
|
|
alias Eventos.Actors.Member
|
|
|
|
alias Eventos.Actors.Actor
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
schema "members" do
|
2018-05-18 09:56:21 +02:00
|
|
|
field :approved, :boolean
|
2017-12-08 09:58:14 +01:00
|
|
|
field :role, :integer
|
2018-05-18 09:56:21 +02:00
|
|
|
belongs_to :parent, Actor
|
|
|
|
belongs_to :actor, Actor
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
2018-01-13 23:33:03 +01:00
|
|
|
def changeset(%Member{} = member, attrs) do
|
|
|
|
member
|
2017-12-08 09:58:14 +01:00
|
|
|
|> cast(attrs, [:role])
|
|
|
|
|> validate_required([:role])
|
|
|
|
end
|
|
|
|
end
|