Add public_content to translations table and rename lang to language
This commit is contained in:
@ -9,9 +9,10 @@ defmodule Outlook.Translations.Translation do
|
||||
schema "translations" do
|
||||
field :content, TranslationUnitsMap
|
||||
field :date, :utc_datetime
|
||||
field :lang, :string, default: "DE"
|
||||
field :language, :string, default: "DE"
|
||||
field :public, :boolean, default: false
|
||||
field :teaser, :string
|
||||
field :public_content, :string
|
||||
field :title, :string
|
||||
field :unauthorized, :boolean, default: false
|
||||
belongs_to :user, User
|
||||
@ -23,10 +24,10 @@ defmodule Outlook.Translations.Translation do
|
||||
@doc false
|
||||
def changeset(translation, attrs) do
|
||||
translation
|
||||
|> cast(attrs, [:lang, :title, :teaser, :date, :public, :unauthorized, :article_id])
|
||||
|> cast(attrs, [:language, :title, :teaser, :date, :public, :unauthorized, :article_id])
|
||||
|> cast(attrs, [:content])
|
||||
|> validate_required([:lang, :title, :content, :date, :public, :unauthorized, :article_id])
|
||||
|> unique_constraint([:lang, :article_id],
|
||||
|> validate_required([:language, :title, :content, :date, :public, :unauthorized, :article_id])
|
||||
|> unique_constraint([:language, :article_id],
|
||||
message: "translation for this language already exists",
|
||||
name: :article_id_lang_unique_index)
|
||||
|> foreign_key_constraint(:article_id)
|
||||
|
||||
@ -49,7 +49,7 @@ defmodule Outlook.Translators do
|
||||
end
|
||||
|
||||
def translate(translation, current_user) do
|
||||
%{lang: target_lang,
|
||||
%{language: target_lang,
|
||||
article: %{content: article_tree, language: source_lang}
|
||||
} = translation
|
||||
article_as_html = prepare_article(article_tree)
|
||||
|
||||
Reference in New Issue
Block a user