feat: prevent join requests with equal mail
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
40a4461d23
commit
086ecdcb1b
22 changed files with 534 additions and 11 deletions
|
|
@ -21,9 +21,24 @@ defmodule MvWeb.JoinRequestLive.Helpers do
|
|||
@doc """
|
||||
Returns the reviewer display string (e.g. email) for a join request, or nil if none.
|
||||
|
||||
Accepts a join request struct or map with optional :reviewed_by_user (loaded User struct).
|
||||
Prefers the denormalized :reviewed_by_display (set on approve/reject) so the UI
|
||||
works for all roles without loading the User resource. Falls back to
|
||||
:reviewed_by_user when loaded (e.g. admin or legacy data before backfill).
|
||||
"""
|
||||
def reviewer_display(req) when is_map(req) do
|
||||
case Map.get(req, :reviewed_by_display) do
|
||||
s when is_binary(s) ->
|
||||
trimmed = String.trim(s)
|
||||
if trimmed == "", do: reviewer_display_from_user(req), else: trimmed
|
||||
|
||||
_ ->
|
||||
reviewer_display_from_user(req)
|
||||
end
|
||||
end
|
||||
|
||||
def reviewer_display(_), do: nil
|
||||
|
||||
defp reviewer_display_from_user(req) do
|
||||
user = Map.get(req, :reviewed_by_user)
|
||||
|
||||
case user do
|
||||
|
|
@ -42,6 +57,4 @@ defmodule MvWeb.JoinRequestLive.Helpers do
|
|||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def reviewer_display(_), do: nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -264,11 +264,16 @@ defmodule MvWeb.JoinRequestLive.Show do
|
|||
defp format_applicant_value(nil), do: nil
|
||||
defp format_applicant_value(""), do: nil
|
||||
defp format_applicant_value(%Date{} = date), do: DateFormatter.format_date(date)
|
||||
defp format_applicant_value(value) when is_map(value), do: format_applicant_value_from_map(value)
|
||||
|
||||
defp format_applicant_value(value) when is_map(value),
|
||||
do: format_applicant_value_from_map(value)
|
||||
|
||||
defp format_applicant_value(value) when is_boolean(value),
|
||||
do: if(value, do: gettext("Yes"), else: gettext("No"))
|
||||
|
||||
defp format_applicant_value(value) when is_binary(value) or is_number(value),
|
||||
do: to_string(value)
|
||||
|
||||
defp format_applicant_value(value), do: to_string(value)
|
||||
|
||||
defp format_applicant_value_from_map(value) do
|
||||
|
|
@ -283,8 +288,10 @@ defmodule MvWeb.JoinRequestLive.Show do
|
|||
end
|
||||
|
||||
defp format_applicant_value_simple(raw, _value) when is_binary(raw), do: raw
|
||||
|
||||
defp format_applicant_value_simple(raw, _value) when is_boolean(raw),
|
||||
do: if(raw, do: gettext("Yes"), else: gettext("No"))
|
||||
|
||||
defp format_applicant_value_simple(raw, _value) when is_integer(raw), do: to_string(raw)
|
||||
defp format_applicant_value_simple(_raw, value), do: to_string(value)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue