2017-12-08 09:58:14 +01:00
|
|
|
defmodule EventosWeb.EventView do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
View for Events
|
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :view
|
2018-05-18 09:56:21 +02:00
|
|
|
alias EventosWeb.{EventView, ActorView, GroupView, AddressView}
|
2018-01-13 23:33:03 +01:00
|
|
|
|
2018-07-09 14:19:24 +02:00
|
|
|
def render("index.json", %{events: events, coord: coord, city: city, country: country}) do
|
|
|
|
%{
|
|
|
|
data: render_many(events, EventView, "event_simple.json"),
|
|
|
|
coord: coord,
|
|
|
|
city: city,
|
|
|
|
country: country,
|
|
|
|
}
|
2018-01-16 19:45:09 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show_simple.json", %{event: event}) do
|
|
|
|
%{data: render_one(event, EventView, "event_simple.json")}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{event: event}) do
|
|
|
|
%{data: render_one(event, EventView, "event.json")}
|
|
|
|
end
|
|
|
|
|
2018-05-19 10:19:21 +02:00
|
|
|
def render("event_for_actor.json", %{event: event}) do
|
|
|
|
%{id: event.id,
|
|
|
|
title: event.title,
|
2018-06-06 17:42:53 +02:00
|
|
|
uuid: event.uuid,
|
2018-05-19 10:19:21 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-16 19:45:09 +01:00
|
|
|
def render("event_simple.json", %{event: event}) do
|
|
|
|
%{id: event.id,
|
|
|
|
title: event.title,
|
|
|
|
description: event.description,
|
|
|
|
begins_on: event.begins_on,
|
|
|
|
ends_on: event.ends_on,
|
2018-06-06 17:42:53 +02:00
|
|
|
uuid: event.uuid,
|
2018-05-19 10:19:21 +02:00
|
|
|
organizer: %{
|
2018-06-06 17:42:53 +02:00
|
|
|
username: event.organizer_actor.preferred_username,
|
|
|
|
display_name: event.organizer_actor.name,
|
|
|
|
avatar: event.organizer_actor.avatar_url,
|
2018-05-19 10:19:21 +02:00
|
|
|
},
|
2018-05-30 14:27:21 +02:00
|
|
|
type: "Event",
|
2018-07-04 14:29:17 +02:00
|
|
|
address_type: event.address_type,
|
2018-01-16 19:45:09 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
def render("event.json", %{event: event}) do
|
|
|
|
%{id: event.id,
|
|
|
|
title: event.title,
|
|
|
|
description: event.description,
|
|
|
|
begins_on: event.begins_on,
|
2018-01-16 19:45:09 +01:00
|
|
|
ends_on: event.ends_on,
|
2018-06-06 17:42:53 +02:00
|
|
|
uuid: event.uuid,
|
2018-07-10 10:00:07 +02:00
|
|
|
organizer: render_one(event.organizer_actor, ActorView, "actor_basic.json"),
|
|
|
|
participants: render_many(event.participants, ActorView, "actor_basic.json"),
|
2018-07-04 14:29:17 +02:00
|
|
|
physical_address: render_one(event.physical_address, AddressView, "address.json"),
|
2018-05-30 14:27:21 +02:00
|
|
|
type: "Event",
|
2018-07-04 14:29:17 +02:00
|
|
|
address_type: event.address_type,
|
2018-01-16 19:45:09 +01:00
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|