philomena/lib/philomena_web/controllers/admin/approval_controller.ex

29 lines
755 B
Elixir
Raw Normal View History

2022-03-24 17:31:57 +01:00
defmodule PhilomenaWeb.Admin.ApprovalController do
use PhilomenaWeb, :controller
alias Philomena.Images.Image
alias Philomena.Repo
import Ecto.Query
plug :verify_authorized
def index(conn, _params) do
images =
Image
|> where(hidden_from_users: false)
|> where(approved: false)
2022-03-24 17:52:57 +01:00
|> order_by(asc: :id)
2023-05-29 13:21:12 +02:00
|> preload([:user, :sources, tags: [:aliases, :aliased_tag]])
2022-03-24 17:31:57 +01:00
|> Repo.paginate(conn.assigns.scrivener)
render(conn, "index.html", title: "Admin - Approval Queue", images: images)
end
defp verify_authorized(conn, _opts) do
case Canada.Can.can?(conn.assigns.current_user, :approve, %Image{}) do
true -> conn
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
end
end
end