feat: more complete metadata diff, scp publishing and rendering context
This commit is contained in:
@@ -9,7 +9,10 @@ defmodule BDS.Posts.Translation do
|
||||
@statuses [:draft, :published]
|
||||
|
||||
schema "post_translations" do
|
||||
belongs_to :post, BDS.Posts.Post, foreign_key: :translation_for, references: :id, type: :string
|
||||
belongs_to :post, BDS.Posts.Post,
|
||||
foreign_key: :translation_for,
|
||||
references: :id,
|
||||
type: :string
|
||||
|
||||
field :project_id, :string
|
||||
field :language, :string
|
||||
@@ -26,22 +29,35 @@ defmodule BDS.Posts.Translation do
|
||||
|
||||
def changeset(translation, attrs) do
|
||||
translation
|
||||
|> cast(attrs, [
|
||||
|> cast(
|
||||
attrs,
|
||||
[
|
||||
:id,
|
||||
:project_id,
|
||||
:translation_for,
|
||||
:language,
|
||||
:title,
|
||||
:excerpt,
|
||||
:content,
|
||||
:status,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:published_at,
|
||||
:file_path,
|
||||
:checksum
|
||||
],
|
||||
empty_values: [nil]
|
||||
)
|
||||
|> validate_required([
|
||||
:id,
|
||||
:project_id,
|
||||
:translation_for,
|
||||
:language,
|
||||
:title,
|
||||
:excerpt,
|
||||
:content,
|
||||
:status,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:published_at,
|
||||
:file_path,
|
||||
:checksum
|
||||
], empty_values: [nil])
|
||||
|> validate_required([:id, :project_id, :translation_for, :language, :title, :status, :created_at, :updated_at])
|
||||
:updated_at
|
||||
])
|
||||
|> foreign_key_constraint(:translation_for)
|
||||
|> unique_constraint(:language, name: :post_translations_translation_language_idx)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user