2018-01-13 22:33:03 +00:00
|
|
|
defmodule Eventos.Groups.Member do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
|
|
|
Represents the membership of an account to a group
|
|
|
|
"""
|
2017-12-08 08:58:14 +00:00
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
2018-01-13 22:33:03 +00:00
|
|
|
alias Eventos.Groups.{Member, Group}
|
|
|
|
alias Eventos.Accounts.Account
|
2017-12-08 08:58:14 +00:00
|
|
|
|
2018-01-13 22:33:03 +00:00
|
|
|
|
|
|
|
schema "members" do
|
2017-12-08 08:58:14 +00:00
|
|
|
field :role, :integer
|
|
|
|
belongs_to :group, Group
|
|
|
|
belongs_to :account, Account
|
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
2018-01-13 22:33:03 +00:00
|
|
|
def changeset(%Member{} = member, attrs) do
|
|
|
|
member
|
2017-12-08 08:58:14 +00:00
|
|
|
|> cast(attrs, [:role])
|
|
|
|
|> validate_required([:role])
|
|
|
|
end
|
|
|
|
end
|