2017-12-08 09:58:14 +01:00
|
|
|
defmodule EventosWeb.GroupView do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
View for Groups
|
|
|
|
"""
|
2017-12-08 09:58:14 +01:00
|
|
|
use EventosWeb, :view
|
2018-05-18 09:56:21 +02:00
|
|
|
alias EventosWeb.{GroupView, ActorView}
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
def render("index.json", %{groups: groups}) do
|
2018-01-16 19:45:09 +01:00
|
|
|
%{data: render_many(groups, GroupView, "group_simple.json")}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{group: group}) do
|
|
|
|
%{data: render_one(group, GroupView, "group.json")}
|
|
|
|
end
|
|
|
|
|
2018-01-16 19:45:09 +01:00
|
|
|
def render("show_simple.json", %{group: group}) do
|
|
|
|
%{data: render_one(group, GroupView, "group_simple.json")}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render("group_simple.json", %{group: group}) do
|
2018-07-27 10:45:35 +02:00
|
|
|
%{
|
|
|
|
id: group.id,
|
2018-01-16 19:45:09 +01:00
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
2018-07-27 10:45:35 +02:00
|
|
|
url: group.url
|
2018-01-16 19:45:09 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
def render("group.json", %{group: group}) do
|
2018-07-27 10:45:35 +02:00
|
|
|
%{
|
|
|
|
id: group.id,
|
2018-01-13 23:33:03 +01:00
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
|
|
|
url: group.url,
|
2018-07-10 10:00:07 +02:00
|
|
|
members: render_many(group.members, ActorView, "actor_basic.json"),
|
2018-01-16 19:45:09 +01:00
|
|
|
events: render_many(group.organized_events, EventView, "event_simple.json")
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|