From 3cf9f4a364ac91cca30799c8379a682139425e71 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Fri, 15 Apr 2022 13:00:42 -0600 Subject: Add comments and vote models; pub/sub voting on posts --- lib/aggiedit/rooms/post.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/aggiedit/rooms/post.ex') diff --git a/lib/aggiedit/rooms/post.ex b/lib/aggiedit/rooms/post.ex index ee9450d..e1aa59a 100644 --- a/lib/aggiedit/rooms/post.ex +++ b/lib/aggiedit/rooms/post.ex @@ -5,18 +5,22 @@ defmodule Aggiedit.Rooms.Post do schema "posts" do field :body, :string field :title, :string + field :score, :integer belongs_to :room, Aggiedit.Rooms.Room belongs_to :user, Aggiedit.Accounts.User belongs_to :upload, Aggiedit.Uploads.Upload + has_many :votes, Aggiedit.Post.Vote + has_many :comments, Aggiedit.Post.Comment + timestamps() end @doc false def changeset(post, attrs) do post - |> cast(attrs, [:title, :body]) + |> cast(attrs, [:title, :body, :score]) |> validate_required([:title, :body]) end -- cgit v1.2.3-70-g09d2