mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
more comprehensive blankness check for personal titles and secondary roles
This commit is contained in:
parent
6ce30ee27c
commit
c79dfd5b21
4 changed files with 14 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue