2022-04-06 14:55:12 -04:00
|
|
|
defmodule Aggiedit.Uploads.Upload do
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
|
|
|
|
schema "uploads" do
|
|
|
|
field :file, :string
|
|
|
|
field :mime, :string
|
|
|
|
field :size, :integer
|
|
|
|
|
|
|
|
belongs_to :user, Aggiedit.Accounts.User
|
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(upload, attrs) do
|
|
|
|
upload
|
|
|
|
|> cast(attrs, [:file, :mime, :size])
|
|
|
|
|> validate_required([:file, :mime, :size])
|
|
|
|
end
|
2022-04-06 20:17:27 -04:00
|
|
|
|
|
|
|
def change_user(upload, user) do
|
|
|
|
change(upload)
|
|
|
|
|> put_assoc(:user, user)
|
|
|
|
end
|
2022-04-06 14:55:12 -04:00
|
|
|
end
|