philomena/lib/philomena_web/views/api/json/dnp_view.ex
SomewhatDamaged 1a6c3731e0
Adds full DNP info to tags (#21)
* Adds full DNP info to tags

* Add dnp view

* Changed DNP to Dnp
2020-09-24 09:46:05 -04:00

24 lines
629 B
Elixir
Executable file

defmodule PhilomenaWeb.Api.Json.DnpView do
use PhilomenaWeb, :view
def render("index.json", %{dnps: dnp, total: total} = assigns) do
%{
dnps: render_many(dnp, PhilomenaWeb.Api.Json.DnpView, "dnp.json", assigns),
total: total
}
end
def render("show.json", %{dnp: dnp} = assigns) do
%{dnp: render_one(dnp, PhilomenaWeb.Api.Json.DnpView, "dnp.json", assigns)}
end
def render("dnp.json", %{dnp: dnp}) do
%{
id: dnp.id,
dnp_type: dnp.dnp_type,
conditions: dnp.conditions,
reason: if(!dnp.hide_reason, do: dnp.reason),
created_at: dnp.created_at
}
end
end