philomena/lib/philomena_web/views/admin/artist_link_view.ex

42 lines
1.2 KiB
Elixir
Raw Normal View History

defmodule PhilomenaWeb.Admin.ArtistLinkView do
2019-12-10 02:21:49 +01:00
use PhilomenaWeb, :view
alias Philomena.Tags.Tag
defp display_order(tags),
do: Tag.display_order(tags)
2019-12-10 02:21:49 +01:00
2020-01-11 05:20:19 +01:00
def link_state_class(%{aasm_state: state}) when state in ["verified", "link_verified"],
do: "success"
def link_state_class(%{aasm_state: state}) when state in ["unverified", "rejected"],
do: "danger"
2019-12-10 02:21:49 +01:00
def link_state_class(%{aasm_state: "contacted"}), do: "warning"
def link_state_class(_link), do: nil
def link_state_name(%{aasm_state: state}) do
state
|> String.replace("_", " ")
|> String.capitalize()
end
def link_scope(conn) do
case conn.params["all"] do
2020-01-11 05:20:19 +01:00
nil -> []
2019-12-10 02:21:49 +01:00
_val -> [all: true]
end
end
def contacted?(%{aasm_state: state}), do: state == "contacted"
def verified?(%{aasm_state: state}), do: state == "verified"
def link_verified?(%{aasm_state: state}), do: state == "link_verified"
def unverified?(%{aasm_state: state}), do: state == "unverified"
def rejected?(%{aasm_state: state}), do: state == "rejected"
def public_text(%{public: true}), do: "Yes"
def public_text(_artist_link), do: "No"
2019-12-10 02:21:49 +01:00
def public?(%{public: public}), do: !!public
end