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
|
|
|
|
%{id: group.id,
|
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
|
|
|
url: group.url,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
def render("group.json", %{group: group}) do
|
|
|
|
%{id: group.id,
|
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
|
|
|
url: group.url,
|
2018-05-18 09:56:21 +02:00
|
|
|
members: render_many(group.members, ActorView, "acccount_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
|