2018-10-11 15:37:39 +00:00
|
|
|
defmodule MobilizonWeb.GroupView do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
|
|
|
View for Groups
|
|
|
|
"""
|
2018-10-11 15:37:39 +00:00
|
|
|
use MobilizonWeb, :view
|
|
|
|
alias MobilizonWeb.{GroupView, ActorView}
|
2018-01-13 22:33:03 +00:00
|
|
|
|
|
|
|
def render("index.json", %{groups: groups}) do
|
2018-01-16 18:45:09 +00:00
|
|
|
%{data: render_many(groups, GroupView, "group_simple.json")}
|
2018-01-13 22:33:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def render("show.json", %{group: group}) do
|
|
|
|
%{data: render_one(group, GroupView, "group.json")}
|
|
|
|
end
|
|
|
|
|
2018-01-16 18:45:09 +00: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 08:45:35 +00:00
|
|
|
%{
|
|
|
|
id: group.id,
|
2018-01-16 18:45:09 +00:00
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
2018-07-27 08:45:35 +00:00
|
|
|
url: group.url
|
2018-01-16 18:45:09 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-13 22:33:03 +00:00
|
|
|
def render("group.json", %{group: group}) do
|
2018-07-27 08:45:35 +00:00
|
|
|
%{
|
|
|
|
id: group.id,
|
2018-01-13 22:33:03 +00:00
|
|
|
title: group.title,
|
|
|
|
description: group.description,
|
|
|
|
suspended: group.suspended,
|
|
|
|
url: group.url,
|
2018-07-10 08:00:07 +00:00
|
|
|
members: render_many(group.members, ActorView, "actor_basic.json"),
|
2018-01-16 18:45:09 +00:00
|
|
|
events: render_many(group.organized_events, EventView, "event_simple.json")
|
|
|
|
}
|
2018-01-13 22:33:03 +00:00
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|