Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-05-18 09:56:21 +02:00
parent e14007bac5
commit f1cb601b46
39 changed files with 1289 additions and 1028 deletions

View File

@@ -3,14 +3,14 @@ defmodule Eventos.Events.Comment do
import Ecto.Changeset
alias Eventos.Events.Event
alias Eventos.Accounts.Account
alias Eventos.Accounts.Comment
alias Eventos.Actors.Actor
alias Eventos.Actors.Comment
schema "comments" do
field :text, :string
field :url, :string
field :local, :boolean, default: true
belongs_to :account, Account, [foreign_key: :account_id]
belongs_to :actor, Actor, [foreign_key: :actor_id]
belongs_to :event, Event, [foreign_key: :event_id]
belongs_to :in_reply_to_comment, Comment, [foreign_key: :in_reply_to_comment_id]
belongs_to :origin_comment, Comment, [foreign_key: :origin_comment_id]
@@ -21,7 +21,7 @@ defmodule Eventos.Events.Comment do
@doc false
def changeset(comment, attrs) do
comment
|> cast(attrs, [:url, :text, :account_id, :event_id, :in_reply_to_comment_id])
|> validate_required([:url, :text, :account_id])
|> cast(attrs, [:url, :text, :actor_id, :event_id, :in_reply_to_comment_id])
|> validate_required([:url, :text, :actor_id])
end
end