record initial source change on upload

This commit is contained in:
byte[] 2019-12-17 14:06:32 -05:00
parent 6d105ffc53
commit b423f8f201
2 changed files with 6 additions and 1 deletions

View file

@ -67,6 +67,11 @@ defmodule Philomena.Images do
|> Image.cache_changeset()
|> repo.update()
end)
|> Multi.run(:source_change, fn repo, %{image: image} ->
%SourceChange{image_id: image.id, initial: true}
|> SourceChange.creation_changeset(attrs, attribution)
|> repo.insert()
end)
|> Multi.run(:added_tag_count, fn repo, %{image: image} ->
tag_ids = image.added_tags |> Enum.map(& &1.id)
tags = Tag |> where([t], t.id in ^tag_ids)

View file

@ -35,7 +35,7 @@
- else
em> not provided yet
= if @source_change_count > 0 do
= if @source_change_count > 1 do
a.button.button--link.button--separate-left href=Routes.image_source_change_path(@conn, :index, @image) title="Source history"
i.fa.fa-history>
| History (