* Improve Directus client - Rearrange and group functions to match - Allow whitespace when searching - provide category to event list * Add event list view * Show band information on festival-ish events * Extract view helpers to reusable module Code is shared between ItemHTML and PageHTML, and they really do not belong in web anyway since it is usable outside web scope as well. * Rename utils to event helpers It is a file that handles the poor design choice of the datamodel for events, so let the module name describe that. * Sync event view - Replace scaffold markup with production markup - Send more data from Directus client
33 lines
781 B
Elixir
33 lines
781 B
Elixir
defmodule Mse25.EventHelpers do
|
|
def bandlist(bands) do
|
|
bands
|
|
|> Enum.map(fn b -> b["artists_id"]["name"] end)
|
|
|> Enum.join(", ")
|
|
|> String.replace(~r/, ([^,]+?)$/, " och \\1")
|
|
end
|
|
|
|
def hilights?(%{"bands" => bands, "category" => category}) do
|
|
_festival_band?(bands, category)
|
|
end
|
|
|
|
def missed?(%{"mia" => bands, "category" => category}) do
|
|
_festival_band?(bands, category)
|
|
end
|
|
|
|
def opening_acts?(%{"bands" => [_ | bands], "category" => "concert"}) do
|
|
not Enum.empty?(bands)
|
|
end
|
|
|
|
def opening_acts?(_) do
|
|
false
|
|
end
|
|
|
|
def _festival_band?(bands, category)
|
|
when category in ["cruise", "openairfestival", "cityfestival", "onedayfestival"] do
|
|
not Enum.empty?(bands)
|
|
end
|
|
|
|
def _festival_band?(_b, _c) do
|
|
false
|
|
end
|
|
end
|