2019-11-12 02:27:09 +01:00
|
|
|
defmodule PhilomenaWeb.ProfileView do
|
|
|
|
use PhilomenaWeb, :view
|
|
|
|
|
|
|
|
def award_order(awards) do
|
|
|
|
awards
|
|
|
|
|> Enum.sort_by(&{!&1.badge.priority, &1.awarded_on})
|
|
|
|
end
|
|
|
|
|
|
|
|
def badge_image(badge, options \\ []) do
|
|
|
|
img_tag(badge_url_root() <> "/" <> badge.image, options)
|
|
|
|
end
|
|
|
|
|
2019-11-12 02:40:31 +01:00
|
|
|
def award_title(%{badge_name: nil} = award),
|
|
|
|
do: award.badge.title
|
|
|
|
def award_title(%{badge_name: ""} = award),
|
|
|
|
do: award.badge.title
|
|
|
|
def award_title(award),
|
|
|
|
do: award.badge_name
|
|
|
|
|
2019-11-12 02:27:09 +01:00
|
|
|
defp badge_url_root do
|
|
|
|
Application.get_env(:philomena, :badge_url_root)
|
|
|
|
end
|
|
|
|
end
|