2019-12-17 03:26:43 +01:00
|
|
|
defmodule PhilomenaWeb.Profile.DetailController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias Philomena.UserNameChanges.UserNameChange
|
2024-07-16 03:19:32 +02:00
|
|
|
alias Philomena.ModNotes
|
2021-09-29 22:24:38 +02:00
|
|
|
alias PhilomenaWeb.MarkdownRenderer
|
2019-12-17 03:26:43 +01:00
|
|
|
alias Philomena.Users.User
|
|
|
|
alias Philomena.Repo
|
|
|
|
import Ecto.Query
|
|
|
|
|
|
|
|
plug PhilomenaWeb.CanaryMapPlug, index: :show_details
|
2020-01-11 05:20:19 +01:00
|
|
|
|
|
|
|
plug :load_and_authorize_resource,
|
|
|
|
model: User,
|
|
|
|
id_field: "slug",
|
|
|
|
id_name: "profile_id",
|
|
|
|
persisted: true
|
2019-12-17 03:26:43 +01:00
|
|
|
|
|
|
|
def index(conn, _params) do
|
|
|
|
user = conn.assigns.user
|
|
|
|
|
2024-07-16 03:19:32 +02:00
|
|
|
renderer = &MarkdownRenderer.render_collection(&1, conn)
|
2024-07-16 03:27:41 +02:00
|
|
|
mod_notes = ModNotes.list_all_mod_notes_by_type_and_id("User", user.id, renderer)
|
2019-12-17 03:26:43 +01:00
|
|
|
|
|
|
|
name_changes =
|
|
|
|
UserNameChange
|
|
|
|
|> where(user_id: ^user.id)
|
|
|
|
|> order_by(desc: :id)
|
|
|
|
|> Repo.all()
|
|
|
|
|
2020-01-11 05:20:19 +01:00
|
|
|
render(conn, "index.html",
|
|
|
|
title: "Profile Details for User `#{user.name}'",
|
|
|
|
mod_notes: mod_notes,
|
|
|
|
name_changes: name_changes
|
|
|
|
)
|
2019-12-17 03:26:43 +01:00
|
|
|
end
|
|
|
|
end
|