philomena/lib/philomena_web/controllers/profile_controller.ex

42 lines
1 KiB
Elixir
Raw Normal View History

2019-11-12 02:27:09 +01:00
defmodule PhilomenaWeb.ProfileController do
use PhilomenaWeb, :controller
2019-12-01 03:22:05 +01:00
alias PhilomenaWeb.ImageLoader
alias Philomena.Users.User
alias Philomena.Interactions
2019-11-12 02:27:09 +01:00
plug :load_and_authorize_resource, model: User, only: :show, id_field: "slug", preload: [awards: :badge, public_links: :tag]
def show(conn, _params) do
current_user = conn.assigns.current_user
user = conn.assigns.user
2019-12-01 03:22:05 +01:00
{:ok, recent_uploads} =
ImageLoader.search_string(
conn,
"uploader_id:#{user.id}",
pagination: %{page_number: 1, page_size: 6}
2019-11-12 02:27:09 +01:00
)
2019-12-01 03:22:05 +01:00
{:ok, recent_faves} =
ImageLoader.search_string(
conn,
"faved_by_id:#{user.id}",
pagination: %{page_number: 1, page_size: 6}
2019-11-12 02:27:09 +01:00
)
2019-12-01 03:22:05 +01:00
interactions =
Interactions.user_interactions([recent_uploads, recent_faves], current_user)
2019-11-12 02:27:09 +01:00
render(
conn,
"show.html",
user: user,
2019-12-01 03:22:05 +01:00
interactions: interactions,
2019-11-12 02:27:09 +01:00
recent_uploads: recent_uploads,
2019-11-18 15:14:26 +01:00
recent_faves: recent_faves,
layout_class: "layout--wide"
2019-11-12 02:27:09 +01:00
)
end
end