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
|
schema "translations" do
|
||||||
field :content, TranslationUnitsMap
|
field :content, TranslationUnitsMap
|
||||||
field :date, :utc_datetime
|
field :date, :utc_datetime
|
||||||
field :lang, :string, default: "DE"
|
field :language, :string, default: "DE"
|
||||||
field :public, :boolean, default: false
|
field :public, :boolean, default: false
|
||||||
field :teaser, :string
|
field :teaser, :string
|
||||||
|
field :public_content, :string
|
||||||
field :title, :string
|
field :title, :string
|
||||||
field :unauthorized, :boolean, default: false
|
field :unauthorized, :boolean, default: false
|
||||||
belongs_to :user, User
|
belongs_to :user, User
|
||||||
@ -23,10 +24,10 @@ defmodule Outlook.Translations.Translation do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(translation, attrs) do
|
def changeset(translation, attrs) do
|
||||||
translation
|
translation
|
||||||
|> cast(attrs, [:lang, :title, :teaser, :date, :public, :unauthorized, :article_id])
|
|> cast(attrs, [:language, :title, :teaser, :date, :public, :unauthorized, :article_id])
|
||||||
|> cast(attrs, [:content])
|
|> cast(attrs, [:content])
|
||||||
|> validate_required([:lang, :title, :content, :date, :public, :unauthorized, :article_id])
|
|> validate_required([:language, :title, :content, :date, :public, :unauthorized, :article_id])
|
||||||
|> unique_constraint([:lang, :article_id],
|
|> unique_constraint([:language, :article_id],
|
||||||
message: "translation for this language already exists",
|
message: "translation for this language already exists",
|
||||||
name: :article_id_lang_unique_index)
|
name: :article_id_lang_unique_index)
|
||||||
|> foreign_key_constraint(:article_id)
|
|> foreign_key_constraint(:article_id)
|
||||||
|
|||||||
@ -49,7 +49,7 @@ defmodule Outlook.Translators do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def translate(translation, current_user) do
|
def translate(translation, current_user) do
|
||||||
%{lang: target_lang,
|
%{language: target_lang,
|
||||||
article: %{content: article_tree, language: source_lang}
|
article: %{content: article_tree, language: source_lang}
|
||||||
} = translation
|
} = translation
|
||||||
article_as_html = prepare_article(article_tree)
|
article_as_html = prepare_article(article_tree)
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{&1}")}>
|
<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{&1}")}>
|
||||||
<:col :let={translation} label="Lang"><%= translation.lang %></:col>
|
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
||||||
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
||||||
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
||||||
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
||||||
|
|||||||
@ -23,7 +23,7 @@ defmodule OutlookWeb.TranslationLive.FormComponent do
|
|||||||
phx-submit="save"
|
phx-submit="save"
|
||||||
>
|
>
|
||||||
<.input field={{f, :article_id}} type="hidden" />
|
<.input field={{f, :article_id}} type="hidden" />
|
||||||
<.input field={{f, :lang}} type="select" label="lang"
|
<.input field={{f, :language}} type="select" label="language"
|
||||||
options={Application.get_env(:outlook,:deepl)[:target_langs]} />
|
options={Application.get_env(:outlook,:deepl)[:target_langs]} />
|
||||||
<.input field={{f, :title}} type="text" label="title" />
|
<.input field={{f, :title}} type="text" label="title" />
|
||||||
<.input field={{f, :teaser}} type="textarea" label="teaser" class="h-28" />
|
<.input field={{f, :teaser}} type="textarea" label="teaser" class="h-28" />
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.table id="translations" rows={@translations} row_click={&JS.navigate(~p"/translations/#{&1}")}>
|
<.table id="translations" rows={@translations} row_click={&JS.navigate(~p"/translations/#{&1}")}>
|
||||||
<:col :let={translation} label="Lang"><%= translation.lang %></:col>
|
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
||||||
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
||||||
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
||||||
<%!-- <:col :let={translation} label="Content"><%= translation.content %></:col> --%>
|
<%!-- <:col :let={translation} label="Content"><%= translation.content %></:col> --%>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.list>
|
<.list>
|
||||||
<:item title="Lang"><%= @translation.lang %></:item>
|
<:item title="Language"><%= @translation.language %></:item>
|
||||||
<:item title="Title"><%= @translation.title %></:item>
|
<:item title="Title"><%= @translation.title %></:item>
|
||||||
<:item title="Teaser"><%= @translation.teaser %></:item>
|
<:item title="Teaser"><%= @translation.teaser %></:item>
|
||||||
<%!-- <:item title="Content"><%= @translation.content %></:item> --%>
|
<%!-- <:item title="Content"><%= @translation.content %></:item> --%>
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
defmodule Outlook.Repo.Migrations.AddPublicContentToTranslations do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:translations) do
|
||||||
|
add :public_content, :text
|
||||||
|
end
|
||||||
|
rename table(:translations), :lang, to: :language
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user