2017-12-08 09:58:14 +01:00
|
|
|
defmodule EventosWeb.AccountView do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
View for Accounts
|
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :view
|
2018-01-16 19:45:09 +01:00
|
|
|
alias EventosWeb.{AccountView, EventView}
|
2018-01-09 17:52:26 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
def render("index.json", %{accounts: accounts}) do
|
2018-01-16 19:45:09 +01:00
|
|
|
%{data: render_many(accounts, AccountView, "acccount_basic.json")}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{account: account}) do
|
|
|
|
%{data: render_one(account, AccountView, "account.json")}
|
|
|
|
end
|
|
|
|
|
2018-01-16 19:45:09 +01:00
|
|
|
def render("show_basic.json", %{account: account}) do
|
|
|
|
%{data: render_one(account, AccountView, "account_basic.json")}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("acccount_basic.json", %{account: account}) do
|
2018-01-13 23:33:03 +01:00
|
|
|
%{id: account.id,
|
2018-01-09 17:52:26 +01:00
|
|
|
username: account.username,
|
2018-01-13 23:33:03 +01:00
|
|
|
domain: account.domain,
|
2018-01-09 17:52:26 +01:00
|
|
|
display_name: account.display_name,
|
2018-01-13 23:33:03 +01:00
|
|
|
description: account.description,
|
2018-01-16 19:45:09 +01:00
|
|
|
# public_key: account.public_key,
|
2018-01-13 23:33:03 +01:00
|
|
|
suspended: account.suspended,
|
|
|
|
uri: account.uri,
|
|
|
|
url: account.url,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("account.json", %{account: account}) do
|
|
|
|
%{id: account.id,
|
|
|
|
username: account.username,
|
2018-01-09 17:52:26 +01:00
|
|
|
domain: account.domain,
|
2018-01-13 23:33:03 +01:00
|
|
|
display_name: account.display_name,
|
|
|
|
description: account.description,
|
2018-01-16 19:45:09 +01:00
|
|
|
# public_key: account.public_key,
|
2018-01-09 17:52:26 +01:00
|
|
|
suspended: account.suspended,
|
|
|
|
uri: account.uri,
|
|
|
|
url: account.url,
|
2018-01-16 19:45:09 +01:00
|
|
|
organized_events: render_many(account.organized_events, EventView, "event_simple.json")
|
2018-01-09 17:52:26 +01:00
|
|
|
}
|
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|