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:
@@ -3,23 +3,27 @@ defmodule EventosWeb.AccountView do
|
||||
View for Accounts
|
||||
"""
|
||||
use EventosWeb, :view
|
||||
alias EventosWeb.AccountView
|
||||
alias EventosWeb.{AccountView, EventView}
|
||||
|
||||
def render("index.json", %{accounts: accounts}) do
|
||||
%{data: render_many(accounts, AccountView, "account_for_user.json")}
|
||||
%{data: render_many(accounts, AccountView, "acccount_basic.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{account: account}) do
|
||||
%{data: render_one(account, AccountView, "account.json")}
|
||||
end
|
||||
|
||||
def render("account_for_user.json", %{account: account}) do
|
||||
def render("show_basic.json", %{account: account}) do
|
||||
%{data: render_one(account, AccountView, "account_basic.json")}
|
||||
end
|
||||
|
||||
def render("acccount_basic.json", %{account: account}) do
|
||||
%{id: account.id,
|
||||
username: account.username,
|
||||
domain: account.domain,
|
||||
display_name: account.display_name,
|
||||
description: account.description,
|
||||
public_key: account.public_key,
|
||||
# public_key: account.public_key,
|
||||
suspended: account.suspended,
|
||||
uri: account.uri,
|
||||
url: account.url,
|
||||
@@ -32,11 +36,11 @@ defmodule EventosWeb.AccountView do
|
||||
domain: account.domain,
|
||||
display_name: account.display_name,
|
||||
description: account.description,
|
||||
public_key: account.public_key,
|
||||
# public_key: account.public_key,
|
||||
suspended: account.suspended,
|
||||
uri: account.uri,
|
||||
url: account.url,
|
||||
organized_events: account.organized_events
|
||||
organized_events: render_many(account.organized_events, EventView, "event_simple.json")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,22 +3,39 @@ defmodule EventosWeb.GroupView do
|
||||
View for Groups
|
||||
"""
|
||||
use EventosWeb, :view
|
||||
alias EventosWeb.GroupView
|
||||
alias EventosWeb.{GroupView, AccountView}
|
||||
|
||||
def render("index.json", %{groups: groups}) do
|
||||
%{data: render_many(groups, GroupView, "group.json")}
|
||||
%{data: render_many(groups, GroupView, "group_simple.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{group: group}) do
|
||||
%{data: render_one(group, GroupView, "group.json")}
|
||||
end
|
||||
|
||||
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,
|
||||
uri: group.uri
|
||||
}
|
||||
end
|
||||
|
||||
def render("group.json", %{group: group}) do
|
||||
%{id: group.id,
|
||||
title: group.title,
|
||||
description: group.description,
|
||||
suspended: group.suspended,
|
||||
url: group.url,
|
||||
uri: group.uri}
|
||||
uri: group.uri,
|
||||
members: render_many(group.members, AccountView, "acccount_basic.json"),
|
||||
events: render_many(group.organized_events, EventView, "event_simple.json")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ defmodule EventosWeb.UserView do
|
||||
def render("user_simple.json", %{user: user}) do
|
||||
%{id: user.id,
|
||||
role: user.role,
|
||||
account: render_one(user.account, AccountView, "account_for_user.json")
|
||||
account: render_one(user.account, AccountView, "acccount_basic.json")
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user