2019-11-25 03:16:22 +01:00
|
|
|
defmodule PhilomenaWeb.Image.SourceChangeController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias Philomena.Images.Image
|
|
|
|
alias Philomena.SourceChanges.SourceChange
|
|
|
|
alias Philomena.Repo
|
|
|
|
import Ecto.Query
|
|
|
|
|
|
|
|
plug PhilomenaWeb.CanaryMapPlug, index: :show
|
|
|
|
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
|
|
|
|
|
2019-11-26 03:57:47 +01:00
|
|
|
def index(conn, _params) do
|
2019-11-25 03:16:22 +01:00
|
|
|
image = conn.assigns.image
|
|
|
|
|
|
|
|
source_changes =
|
|
|
|
SourceChange
|
|
|
|
|> where(image_id: ^image.id)
|
|
|
|
|> preload([:user, image: [:user, :tags]])
|
|
|
|
|> order_by(desc: :created_at)
|
|
|
|
|> Repo.paginate(conn.assigns.scrivener)
|
2020-01-11 05:20:19 +01:00
|
|
|
|
|
|
|
render(conn, "index.html",
|
|
|
|
title: "Source Changes on Image #{image.id}",
|
|
|
|
image: image,
|
|
|
|
source_changes: source_changes
|
|
|
|
)
|
2019-11-25 03:16:22 +01:00
|
|
|
end
|
2019-12-16 20:24:38 +01:00
|
|
|
end
|