redirect_path, user_abbrv, last_message_path

This commit is contained in:
Liam 2024-04-28 21:11:56 -04:00
parent c506ef884e
commit 42039491b6
11 changed files with 16 additions and 16 deletions

View file

@ -53,7 +53,7 @@ defmodule PhilomenaWeb.ReportController do
:info, :info,
"Your report has been received and will be checked by staff shortly." "Your report has been received and will be checked by staff shortly."
) )
|> redirect(to: redirect_path(conn, conn.assigns.current_user)) |> redirect(to: redirect_path(conn.assigns.current_user))
{:error, changeset} -> {:error, changeset} ->
# Note that we are depending on the controller that called # Note that we are depending on the controller that called
@ -100,8 +100,8 @@ defmodule PhilomenaWeb.ReportController do
reports_open >= max_reports() reports_open >= max_reports()
end end
defp redirect_path(_conn, nil), do: "/" defp redirect_path(nil), do: "/"
defp redirect_path(conn, _user), do: ~p"/reports" defp redirect_path(_user), do: ~p"/reports"
defp max_reports do defp max_reports do
5 5

View file

@ -35,7 +35,7 @@ h1 Fingerprint Bans
td td
=> pretty_time ban.created_at => pretty_time ban.created_at
= user_abbrv @conn, ban.banning_user = user_abbrv ban.banning_user
td class=ban_row_class(ban) td class=ban_row_class(ban)
= pretty_time ban.valid_until = pretty_time ban.valid_until

View file

@ -32,7 +32,7 @@ table.table
td class=report_row_class(report) td class=report_row_class(report)
=> pretty_state(report) => pretty_state(report)
= user_abbrv @conn, report.admin = user_abbrv report.admin
td td
=> link "Show", to: ~p"/admin/reports/#{report}" => link "Show", to: ~p"/admin/reports/#{report}"

View file

@ -35,7 +35,7 @@ h1 Subnet Bans
td td
=> pretty_time ban.created_at => pretty_time ban.created_at
= user_abbrv @conn, ban.banning_user = user_abbrv ban.banning_user
td class=ban_row_class(ban) td class=ban_row_class(ban)
= pretty_time ban.valid_until = pretty_time ban.valid_until

View file

@ -35,7 +35,7 @@ h1 User Bans
td td
=> pretty_time ban.created_at => pretty_time ban.created_at
= user_abbrv @conn, ban.banning_user = user_abbrv ban.banning_user
td class=ban_row_class(ban) td class=ban_row_class(ban)
= pretty_time ban.valid_until = pretty_time ban.valid_until

View file

@ -36,7 +36,7 @@ h1 My Conversations
td.table--communication-list__stats td.table--communication-list__stats
= render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other_party(@current_user, c)}, conn: @conn = render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other_party(@current_user, c)}, conn: @conn
td.table--communication-list__options td.table--communication-list__options
=> link "Last message", to: last_message_path(@conn, c, count) => link "Last message", to: last_message_path(c, count)
' • ' •
=> link "Hide", to: ~p"/conversations/#{c}/hide", data: [method: "post"], data: [confirm: "Are you really, really sure?"] => link "Hide", to: ~p"/conversations/#{c}/hide", data: [method: "post"], data: [confirm: "Are you really, really sure?"]

View file

@ -116,7 +116,7 @@
.flex__grow.center .flex__grow.center
=> pretty_time(award.awarded_on) => pretty_time(award.awarded_on)
= if manages_awards?(@conn) do = if manages_awards?(@conn) do
= user_abbrv(@conn, award.awarded_by) = user_abbrv(award.awarded_by)
= if manages_awards?(@conn) do = if manages_awards?(@conn) do
.flex__grow.center .flex__grow.center

View file

@ -1,8 +1,8 @@
defmodule PhilomenaWeb.Admin.BanView do defmodule PhilomenaWeb.Admin.BanView do
alias PhilomenaWeb.ProfileView alias PhilomenaWeb.ProfileView
def user_abbrv(conn, user), def user_abbrv(user),
do: ProfileView.user_abbrv(conn, user) do: ProfileView.user_abbrv(user)
def ban_row_class(%{valid_until: until, enabled: enabled}) do def ban_row_class(%{valid_until: until, enabled: enabled}) do
now = DateTime.utc_now() now = DateTime.utc_now()

View file

@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Admin.ReportView do
defp pretty_state(report), defp pretty_state(report),
do: ReportView.pretty_state(report) do: ReportView.pretty_state(report)
defp user_abbrv(conn, user), defp user_abbrv(user),
do: ProfileView.user_abbrv(conn, user) do: ProfileView.user_abbrv(user)
defp current?(current_user, user), defp current?(current_user, user),
do: ProfileView.current?(current_user, user) do: ProfileView.current?(current_user, user)

View file

@ -32,7 +32,7 @@ defmodule PhilomenaWeb.ConversationView do
end end
end end
def last_message_path(conn, conversation, count) do def last_message_path(conversation, count) do
page = trunc(Float.ceil(count / 25)) page = trunc(Float.ceil(count / 25))
~p"/conversations/#{conversation}?#{[page: page]}" ~p"/conversations/#{conversation}?#{[page: page]}"

View file

@ -77,7 +77,7 @@ defmodule PhilomenaWeb.ProfileView do
def enabled_text(true), do: "Enabled" def enabled_text(true), do: "Enabled"
def enabled_text(_else), do: "Disabled" def enabled_text(_else), do: "Disabled"
def user_abbrv(conn, %{name: name} = user) do def user_abbrv(%{name: name} = user) do
abbrv = abbrv =
String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name)) String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name))
@ -86,7 +86,7 @@ defmodule PhilomenaWeb.ProfileView do
link(abbrv, to: ~p"/profiles/#{user}") link(abbrv, to: ~p"/profiles/#{user}")
end end
def user_abbrv(_conn, _user), do: content_tag(:span, "(n/a)") def user_abbrv(_user), do: content_tag(:span, "(n/a)")
defp initials_abbrv(name) do defp initials_abbrv(name) do
case String.split(name, " ", parts: 4) do case String.split(name, " ", parts: 4) do