mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-18 06:57:59 +01:00
28 lines
784 B
Elixir
28 lines
784 B
Elixir
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
|
|
|
|
def index(conn, _params) do
|
|
image = conn.assigns.image
|
|
|
|
source_changes =
|
|
SourceChange
|
|
|> where(image_id: ^image.id)
|
|
|> preload([:user, image: [:user, :sources, tags: :aliases]])
|
|
|> order_by(desc: :id)
|
|
|> Repo.paginate(conn.assigns.scrivener)
|
|
|
|
render(conn, "index.html",
|
|
title: "Source Changes on Image #{image.id}",
|
|
image: image,
|
|
source_changes: source_changes
|
|
)
|
|
end
|
|
end
|