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.Tags.Tag
alias Philomena.Repo
plug PhilomenaWeb.FilterBannedUsersPlug
plug :authorize_filter

View file

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

View file

@ -3,7 +3,6 @@ defmodule PhilomenaWeb.Tag.WatchController do
alias Philomena.Tags.Tag
alias Philomena.Users
alias Philomena.Repo
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)
end
defp personal_title(labels, %{personal_title: t}) when t not in [nil, ""],
do: [{"label--primary", t} | labels]
defp personal_title(labels, _user),
do: labels
defp personal_title(labels, %{personal_title: t}) do
case blank?(t) do
true -> 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, ""],
do: [{"label--warning", t} | labels]
defp secondary_role(labels, _user),
do: labels
defp secondary_role(labels, %{secondary_role: t}) do
case blank?(t) do
true -> 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"}),
do: [{"label--danger", "Site Administrator"} | labels]