mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Fix single-source saving bug
This commit is contained in:
parent
1bd5e897cb
commit
9e35238cab
2 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
alias Philomena.SourceChanges.SourceChange
|
alias Philomena.SourceChanges.SourceChange
|
||||||
alias Philomena.UserStatistics
|
alias Philomena.UserStatistics
|
||||||
alias Philomena.Images.Image
|
alias Philomena.Images.Image
|
||||||
|
alias Philomena.Images.Source
|
||||||
alias Philomena.Images
|
alias Philomena.Images
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
@ -41,7 +42,9 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
PhilomenaWeb.Api.Json.ImageView.render("show.json", %{image: image, interactions: []})
|
PhilomenaWeb.Api.Json.ImageView.render("show.json", %{image: image, interactions: []})
|
||||||
)
|
)
|
||||||
|
|
||||||
changeset = Images.change_image(image)
|
changeset =
|
||||||
|
%{image | sources: sources_for_edit(image.sources)}
|
||||||
|
|> Images.change_image()
|
||||||
|
|
||||||
source_change_count =
|
source_change_count =
|
||||||
SourceChange
|
SourceChange
|
||||||
|
@ -74,4 +77,9 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: this is duplicated in ImageController
|
||||||
|
defp sources_for_edit(), do: [%Source{}]
|
||||||
|
defp sources_for_edit([]), do: sources_for_edit()
|
||||||
|
defp sources_for_edit(sources), do: sources
|
||||||
end
|
end
|
||||||
|
|
|
@ -219,6 +219,7 @@ defmodule PhilomenaWeb.ImageController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: this is duplicated in Image.SourceController
|
||||||
defp sources_for_edit(), do: [%Source{}]
|
defp sources_for_edit(), do: [%Source{}]
|
||||||
defp sources_for_edit([]), do: sources_for_edit()
|
defp sources_for_edit([]), do: sources_for_edit()
|
||||||
defp sources_for_edit(sources), do: sources
|
defp sources_for_edit(sources), do: sources
|
||||||
|
|
Loading…
Reference in a new issue