2018-05-18 09:56:21 +02:00
|
|
|
defmodule EventosWeb.ActorView do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
2018-05-18 09:56:21 +02:00
|
|
|
View for Actors
|
2018-01-14 17:56:50 +01:00
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :view
|
2018-05-18 09:56:21 +02:00
|
|
|
alias EventosWeb.{ActorView, EventView}
|
2018-01-09 17:52:26 +01:00
|
|
|
|
2018-05-18 09:56:21 +02:00
|
|
|
def render("index.json", %{actors: actors}) do
|
|
|
|
%{data: render_many(actors, ActorView, "acccount_basic.json")}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
|
2018-05-18 09:56:21 +02:00
|
|
|
def render("show.json", %{actor: actor}) do
|
|
|
|
%{data: render_one(actor, ActorView, "actor.json")}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
|
2018-05-18 09:56:21 +02:00
|
|
|
def render("show_basic.json", %{actor: actor}) do
|
|
|
|
%{data: render_one(actor, ActorView, "actor_basic.json")}
|
2018-01-16 19:45:09 +01:00
|
|
|
end
|
|
|
|
|
2018-05-18 09:56:21 +02:00
|
|
|
def render("acccount_basic.json", %{actor: actor}) do
|
|
|
|
%{id: actor.id,
|
2018-05-19 10:19:21 +02:00
|
|
|
username: actor.preferred_username,
|
2018-05-18 09:56:21 +02:00
|
|
|
domain: actor.domain,
|
2018-05-19 10:19:21 +02:00
|
|
|
display_name: actor.name,
|
|
|
|
description: actor.summary,
|
2018-05-30 14:27:21 +02:00
|
|
|
type: actor.type,
|
2018-05-18 09:56:21 +02:00
|
|
|
# public_key: actor.public_key,
|
|
|
|
suspended: actor.suspended,
|
|
|
|
url: actor.url,
|
2018-01-13 23:33:03 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-05-18 09:56:21 +02:00
|
|
|
def render("actor.json", %{actor: actor}) do
|
|
|
|
%{id: actor.id,
|
2018-05-19 10:19:21 +02:00
|
|
|
username: actor.preferred_username,
|
2018-05-18 09:56:21 +02:00
|
|
|
domain: actor.domain,
|
2018-05-19 10:19:21 +02:00
|
|
|
display_name: actor.name,
|
|
|
|
description: actor.summary,
|
2018-05-30 14:27:21 +02:00
|
|
|
type: actor.type,
|
2018-05-18 09:56:21 +02:00
|
|
|
# public_key: actor.public_key,
|
|
|
|
suspended: actor.suspended,
|
|
|
|
url: actor.url,
|
2018-05-19 10:19:21 +02:00
|
|
|
organized_events: render_many(actor.organized_events, EventView, "event_for_actor.json")
|
2018-01-09 17:52:26 +01:00
|
|
|
}
|
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|