Fix front-end, allow events to be created by a group, allow to get sessions from an event

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-01-16 19:45:09 +01:00
parent 7a98674e59
commit 67ef32432e
29 changed files with 278 additions and 82 deletions

View File

@@ -3,21 +3,38 @@ defmodule EventosWeb.EventView do
View for Events
"""
use EventosWeb, :view
alias EventosWeb.EventView
alias EventosWeb.{EventView, AccountView, GroupView}
def render("index.json", %{events: events}) do
%{data: render_many(events, EventView, "event.json")}
%{data: render_many(events, EventView, "event_simple.json")}
end
def render("show_simple.json", %{event: event}) do
%{data: render_one(event, EventView, "event_simple.json")}
end
def render("show.json", %{event: event}) do
%{data: render_one(event, EventView, "event.json")}
end
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,
}
end
def render("event.json", %{event: event}) do
%{id: event.id,
title: event.title,
description: event.description,
begins_on: event.begins_on,
ends_on: event.ends_on}
ends_on: event.ends_on,
organizer: render_one(event.organizer_account, AccountView, "acccount_basic.json"),
group: render_one(event.organizer_group, GroupView, "group_basic.json"),
participants: render_many(event.participants, AccountView, "show_basic.json"),
}
end
end