@@ -1,3 +1,15 @@
|
||||
defmodule EventosWeb.AccountView do
|
||||
use EventosWeb, :view
|
||||
|
||||
def render("account.json", %{"account": account}) do
|
||||
%{
|
||||
username: account.username,
|
||||
description: account.description,
|
||||
display_name: account.display_name,
|
||||
domain: account.domain,
|
||||
suspended: account.suspended,
|
||||
uri: account.uri,
|
||||
url: account.url,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
3
lib/eventos_web/views/app_view.ex
Normal file
3
lib/eventos_web/views/app_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule EventosWeb.AppView do
|
||||
use EventosWeb, :view
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule EventosWeb.SessionView do
|
||||
use EventosWeb, :view
|
||||
|
||||
def render("token.json", %{token: token}) do
|
||||
%{token: token}
|
||||
def render("token.json", %{token: token, user: user}) do
|
||||
%{token: token, user: render_one(user, EventosWeb.UserView, "user.json")}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
defmodule EventosWeb.UserView do
|
||||
use EventosWeb, :view
|
||||
import Logger
|
||||
|
||||
def render("user.json", %{"user": user}) do
|
||||
%{
|
||||
email: user.email,
|
||||
account: render_one(user.account, EventosWeb.AccountView, "account.json"),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user