b54dae7e15
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
27 lines
617 B
Elixir
27 lines
617 B
Elixir
defmodule Mobilizon.Events.Category do
|
|
@moduledoc """
|
|
Represents a category for events
|
|
"""
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
alias Mobilizon.Events.Category
|
|
use Arc.Ecto.Schema
|
|
|
|
schema "categories" do
|
|
field(:description, :string)
|
|
field(:picture, MobilizonWeb.Uploaders.Category.Type)
|
|
field(:title, :string, null: false)
|
|
|
|
timestamps()
|
|
end
|
|
|
|
@doc false
|
|
def changeset(%Category{} = category, attrs) do
|
|
category
|
|
|> cast(attrs, [:title, :description])
|
|
|> cast_attachments(attrs, [:picture])
|
|
|> validate_required([:title])
|
|
|> unique_constraint(:title)
|
|
end
|
|
end
|