more comprehensive blankness check for personal titles and secondary roles

This commit is contained in:
byte[] 2019-12-07 21:30:47 -05:00
parent 6ce30ee27c
commit c79dfd5b21
4 changed files with 14 additions and 11 deletions

View file

@ -3,7 +3,6 @@ defmodule PhilomenaWeb.Filter.HideController do
alias Philomena.Filters alias Philomena.Filters
alias Philomena.Tags.Tag alias Philomena.Tags.Tag
alias Philomena.Repo
plug PhilomenaWeb.FilterBannedUsersPlug plug PhilomenaWeb.FilterBannedUsersPlug
plug :authorize_filter plug :authorize_filter

View file

@ -3,7 +3,6 @@ defmodule PhilomenaWeb.Filter.SpoilerController do
alias Philomena.Filters alias Philomena.Filters
alias Philomena.Tags.Tag alias Philomena.Tags.Tag
alias Philomena.Repo
plug PhilomenaWeb.FilterBannedUsersPlug plug PhilomenaWeb.FilterBannedUsersPlug
plug :authorize_filter plug :authorize_filter

View file

@ -3,7 +3,6 @@ defmodule PhilomenaWeb.Tag.WatchController do
alias Philomena.Tags.Tag alias Philomena.Tags.Tag
alias Philomena.Users alias Philomena.Users
alias Philomena.Repo
plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true

View file

@ -49,15 +49,21 @@ defmodule PhilomenaWeb.UserAttributionView do
|> staff_role(user) |> staff_role(user)
end end
defp personal_title(labels, %{personal_title: t}) when t not in [nil, ""], defp personal_title(labels, %{personal_title: t}) do
do: [{"label--primary", t} | labels] case blank?(t) do
defp personal_title(labels, _user), true -> labels
do: labels false -> [{"label--primary", t} | labels]
end
end
defp personal_title(labels, _user), do: labels
defp secondary_role(labels, %{secondary_role: t}) when t not in [nil, ""], defp secondary_role(labels, %{secondary_role: t}) do
do: [{"label--warning", t} | labels] case blank?(t) do
defp secondary_role(labels, _user), true -> labels
do: labels false -> [{"label--warning", t} | labels]
end
end
defp secondary_role(labels, _user), do: labels
defp staff_role(labels, %{hide_default_role: false, role: "admin"}), defp staff_role(labels, %{hide_default_role: false, role: "admin"}),
do: [{"label--danger", "Site Administrator"} | labels] do: [{"label--danger", "Site Administrator"} | labels]