Add Translations

mix phx.gen.live Translations Translation translations \
  lang:string title:string teaser:text content:map \
  date:utc_datetime user_id:references:users \
  public:boolean unauthorized:boolean article_id:references:articles
This commit is contained in:
Thelonius Kort
2022-12-26 18:45:40 +01:00
parent f7f1e1a284
commit f66521dba8
13 changed files with 600 additions and 0 deletions

View File

@ -0,0 +1,28 @@
defmodule Outlook.Translations.Translation do
use Ecto.Schema
import Ecto.Changeset
alias Outlook.Accounts.User
alias Outlook.Articles.Article
schema "translations" do
field :content, :map
field :date, :utc_datetime
field :lang, :string
field :public, :boolean, default: false
field :teaser, :string
field :title, :string
field :unauthorized, :boolean, default: false
belongs_to :user, User
belongs_to :article, Article
timestamps()
end
@doc false
def changeset(translation, attrs) do
translation
|> cast(attrs, [:lang, :title, :teaser, :content, :date, :public, :unauthorized])
|> validate_required([:lang, :title, :teaser, :content, :date, :public, :unauthorized])
end
end