mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
redirect_path, user_abbrv, last_message_path
This commit is contained in:
parent
37f949a9c5
commit
2184d17086
11 changed files with 16 additions and 16 deletions
|
@ -53,7 +53,7 @@ defmodule PhilomenaWeb.ReportController do
|
|||
:info,
|
||||
"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} ->
|
||||
# Note that we are depending on the controller that called
|
||||
|
@ -100,8 +100,8 @@ defmodule PhilomenaWeb.ReportController do
|
|||
reports_open >= max_reports()
|
||||
end
|
||||
|
||||
defp redirect_path(_conn, nil), do: "/"
|
||||
defp redirect_path(conn, _user), do: ~p"/reports"
|
||||
defp redirect_path(nil), do: "/"
|
||||
defp redirect_path(_user), do: ~p"/reports"
|
||||
|
||||
defp max_reports do
|
||||
5
|
||||
|
|
|
@ -35,7 +35,7 @@ h1 Fingerprint Bans
|
|||
|
||||
td
|
||||
=> pretty_time ban.created_at
|
||||
= user_abbrv @conn, ban.banning_user
|
||||
= user_abbrv ban.banning_user
|
||||
|
||||
td class=ban_row_class(ban)
|
||||
= pretty_time ban.valid_until
|
||||
|
|
|
@ -32,7 +32,7 @@ table.table
|
|||
|
||||
td class=report_row_class(report)
|
||||
=> pretty_state(report)
|
||||
= user_abbrv @conn, report.admin
|
||||
= user_abbrv report.admin
|
||||
td
|
||||
=> link "Show", to: ~p"/admin/reports/#{report}"
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ h1 Subnet Bans
|
|||
|
||||
td
|
||||
=> pretty_time ban.created_at
|
||||
= user_abbrv @conn, ban.banning_user
|
||||
= user_abbrv ban.banning_user
|
||||
|
||||
td class=ban_row_class(ban)
|
||||
= pretty_time ban.valid_until
|
||||
|
|
|
@ -35,7 +35,7 @@ h1 User Bans
|
|||
|
||||
td
|
||||
=> pretty_time ban.created_at
|
||||
= user_abbrv @conn, ban.banning_user
|
||||
= user_abbrv ban.banning_user
|
||||
|
||||
td class=ban_row_class(ban)
|
||||
= pretty_time ban.valid_until
|
||||
|
|
|
@ -36,7 +36,7 @@ h1 My Conversations
|
|||
td.table--communication-list__stats
|
||||
= render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other_party(@current_user, c)}, conn: @conn
|
||||
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?"]
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
.flex__grow.center
|
||||
=> pretty_time(award.awarded_on)
|
||||
= if manages_awards?(@conn) do
|
||||
= user_abbrv(@conn, award.awarded_by)
|
||||
= user_abbrv(award.awarded_by)
|
||||
|
||||
= if manages_awards?(@conn) do
|
||||
.flex__grow.center
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
defmodule PhilomenaWeb.Admin.BanView do
|
||||
alias PhilomenaWeb.ProfileView
|
||||
|
||||
def user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
def user_abbrv(user),
|
||||
do: ProfileView.user_abbrv(user)
|
||||
|
||||
def ban_row_class(%{valid_until: until, enabled: enabled}) do
|
||||
now = DateTime.utc_now()
|
||||
|
|
|
@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Admin.ReportView do
|
|||
defp pretty_state(report),
|
||||
do: ReportView.pretty_state(report)
|
||||
|
||||
defp user_abbrv(conn, user),
|
||||
do: ProfileView.user_abbrv(conn, user)
|
||||
defp user_abbrv(user),
|
||||
do: ProfileView.user_abbrv(user)
|
||||
|
||||
defp current?(current_user, user),
|
||||
do: ProfileView.current?(current_user, user)
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule PhilomenaWeb.ConversationView do
|
|||
end
|
||||
end
|
||||
|
||||
def last_message_path(conn, conversation, count) do
|
||||
def last_message_path(conversation, count) do
|
||||
page = trunc(Float.ceil(count / 25))
|
||||
|
||||
~p"/conversations/#{conversation}?#{[page: page]}"
|
||||
|
|
|
@ -77,7 +77,7 @@ defmodule PhilomenaWeb.ProfileView do
|
|||
def enabled_text(true), do: "Enabled"
|
||||
def enabled_text(_else), do: "Disabled"
|
||||
|
||||
def user_abbrv(conn, %{name: name} = user) do
|
||||
def user_abbrv(%{name: name} = user) do
|
||||
abbrv =
|
||||
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}")
|
||||
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
|
||||
case String.split(name, " ", parts: 4) do
|
||||
|
|
Loading…
Reference in a new issue