add interactions, proper filtering to tag controller

This commit is contained in:
byte[] 2019-11-27 19:24:09 -05:00
parent a489d00aed
commit 06c48f6916

View file

@ -2,6 +2,7 @@ defmodule PhilomenaWeb.TagController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias Philomena.{Images.Image, Tags, Tags.Tag} alias Philomena.{Images.Image, Tags, Tags.Tag}
alias Philomena.Interactions
import Ecto.Query import Ecto.Query
def index(conn, params) do def index(conn, params) do
@ -25,13 +26,14 @@ defmodule PhilomenaWeb.TagController do
tag = Tags.get_tag!(slug) tag = Tags.get_tag!(slug)
query = conn.assigns.compiled_filter query = conn.assigns.compiled_filter
user = conn.assigns.current_user
images = images =
Image.search_records( Image.search_records(
%{ %{
query: %{ query: %{
bool: %{ bool: %{
must_not: query, must_not: [query, %{term: %{hidden_from_users: true}}],
must: %{term: %{"namespaced_tags.name": tag.name}} must: %{term: %{"namespaced_tags.name": tag.name}}
} }
}, },
@ -41,6 +43,9 @@ defmodule PhilomenaWeb.TagController do
Image |> preload([:tags, :user]) Image |> preload([:tags, :user])
) )
render(conn, "show.html", tag: tag, images: images, layout_class: "layout--wide") interactions =
Interactions.user_interactions(images, user)
render(conn, "show.html", tag: tag, interactions: interactions, images: images, layout_class: "layout--wide")
end end
end end