add basic user attribution

This commit is contained in:
byte[] 2019-10-03 21:03:33 -04:00
parent 6a461ec927
commit 6e5d81191d
5 changed files with 14 additions and 5 deletions

View file

@ -5,7 +5,7 @@ defmodule PhilomenaWeb.ImageController do
import Ecto.Query import Ecto.Query
plug ImageFilter plug ImageFilter
plug :load_and_authorize_resource, model: Image, only: :show, preload: :tags plug :load_and_authorize_resource, model: Image, only: :show, preload: [:tags, :user]
def index(conn, _params) do def index(conn, _params) do
query = conn.assigns.compiled_filter query = conn.assigns.compiled_filter
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.ImageController do
query: %{bool: %{must_not: query}}, query: %{bool: %{must_not: query}},
sort: %{created_at: :desc} sort: %{created_at: :desc}
}, },
Image |> preload(:tags) Image |> preload([:tags, :user])
) )
render(conn, "index.html", images: images) render(conn, "index.html", images: images)

View file

@ -38,7 +38,7 @@ defmodule PhilomenaWeb.TagController do
}, },
sort: %{created_at: :desc} sort: %{created_at: :desc}
}, },
Image |> preload(:tags) Image |> preload([:tags, :user])
) )
render(conn, "show.html", tag: tag, images: images) render(conn, "show.html", tag: tag, images: images)

View file

@ -48,8 +48,10 @@
| DS | DS
.image-metabar.flex.flex--wrap.block__header--user-credit.center--layout#extrameta .image-metabar.flex.flex--wrap.block__header--user-credit.center--layout#extrameta
div div
| Uploaded ' Uploaded
=<> pretty_time(@image.created_at) => pretty_time(@image.created_at)
' by
=> render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @image
span.image-size span.image-size
| &nbsp; | &nbsp;
= @image.image_width = @image.image_width

View file

@ -0,0 +1,5 @@
= if !!@object.user and !@object.anonymous do
strong<> = @object.user.name
- else
strong<>
' Background Pony

View file

@ -0,0 +1,2 @@
= if !!@object.user do
strong<>= @object.user.name