@@ -1,68 +0,0 @@
|
||||
defmodule MobilizonWeb.ActorView do
|
||||
@moduledoc """
|
||||
View for Actors
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.{ActorView, EventView, MemberView}
|
||||
alias Mobilizon.Actors
|
||||
|
||||
def render("index.json", %{actors: actors}) do
|
||||
%{data: render_many(actors, ActorView, "actor_basic.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{actor: actor}) do
|
||||
%{data: render_one(actor, ActorView, "actor.json")}
|
||||
end
|
||||
|
||||
def render("show_basic.json", %{actor: actor}) do
|
||||
%{data: render_one(actor, ActorView, "actor_basic.json")}
|
||||
end
|
||||
|
||||
def render("actor_basic.json", %{actor: actor}) do
|
||||
%{
|
||||
id: actor.id,
|
||||
username: actor.preferred_username,
|
||||
domain: actor.domain,
|
||||
display_name: actor.name,
|
||||
description: actor.summary,
|
||||
type: actor.type,
|
||||
# public_key: actor.public_key,
|
||||
suspended: actor.suspended,
|
||||
url: actor.url,
|
||||
avatar: actor.avatar_url
|
||||
}
|
||||
end
|
||||
|
||||
def render("actor.json", %{actor: actor}) do
|
||||
output = %{
|
||||
id: actor.id,
|
||||
username: actor.preferred_username,
|
||||
domain: actor.domain,
|
||||
display_name: actor.name,
|
||||
description: actor.summary,
|
||||
type: actor.type,
|
||||
# public_key: actor.public_key,
|
||||
suspended: actor.suspended,
|
||||
url: actor.url,
|
||||
avatar: actor.avatar_url,
|
||||
banner: actor.banner_url,
|
||||
organized_events: render_many(actor.organized_events, EventView, "event_for_actor.json")
|
||||
}
|
||||
|
||||
import Logger
|
||||
Logger.debug(inspect(actor.type))
|
||||
|
||||
if actor.type == :Group do
|
||||
Logger.debug("I'm a group !")
|
||||
|
||||
Map.put(
|
||||
output,
|
||||
:members,
|
||||
render_many(Actors.members_for_group(actor), MemberView, "member.json")
|
||||
)
|
||||
else
|
||||
Logger.debug("not a group")
|
||||
output
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,42 +0,0 @@
|
||||
defmodule MobilizonWeb.AddressView do
|
||||
@moduledoc """
|
||||
View for addresses
|
||||
"""
|
||||
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.AddressView
|
||||
|
||||
def render("index.json", %{addresses: addresses}) do
|
||||
%{data: render_many(addresses, AddressView, "address.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{address: address}) do
|
||||
%{data: render_one(address, AddressView, "address.json")}
|
||||
end
|
||||
|
||||
def render("address.json", %{address: address}) do
|
||||
%{
|
||||
id: address.id,
|
||||
description: address.description,
|
||||
floor: address.floor,
|
||||
addressCountry: address.addressCountry,
|
||||
addressLocality: address.addressLocality,
|
||||
addressRegion: address.addressRegion,
|
||||
postalCode: address.postalCode,
|
||||
streetAddress: address.streetAddress,
|
||||
geom: render_one(address.geom, AddressView, "geom.json")
|
||||
}
|
||||
end
|
||||
|
||||
def render("geom.json", %{address: %Geo.Point{} = point}) do
|
||||
[lat, lon] = Tuple.to_list(point.coordinates)
|
||||
|
||||
%{
|
||||
type: "point",
|
||||
data: %{
|
||||
latitude: lat,
|
||||
longitude: lon
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
defmodule MobilizonWeb.BotView do
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.BotView
|
||||
|
||||
def render("index.json", %{bots: bots}) do
|
||||
%{data: render_many(bots, BotView, "bot.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{bot: bot}) do
|
||||
%{data: render_one(bot, BotView, "bot.json")}
|
||||
end
|
||||
|
||||
def render("bot.json", %{bot: bot}) do
|
||||
%{id: bot.id, source: bot.source, type: bot.type}
|
||||
end
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
defmodule MobilizonWeb.CategoryView do
|
||||
@moduledoc """
|
||||
View for Categories
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.CategoryView
|
||||
|
||||
def render("index.json", %{categories: categories}) do
|
||||
%{data: render_many(categories, CategoryView, "category.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{category: category}) do
|
||||
%{data: render_one(category, CategoryView, "category.json")}
|
||||
end
|
||||
|
||||
def render("category.json", %{category: category}) do
|
||||
%{
|
||||
id: category.id,
|
||||
title: category.title,
|
||||
description: category.description,
|
||||
picture: category.picture
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
defmodule MobilizonWeb.CommentView do
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.CommentView
|
||||
|
||||
def render("index.json", %{comments: comments}) do
|
||||
%{data: render_many(comments, CommentView, "comment.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{comment: comment}) do
|
||||
%{data: render_one(comment, CommentView, "comment.json")}
|
||||
end
|
||||
|
||||
def render("comment.json", %{comment: comment}) do
|
||||
%{id: comment.id, uuid: comment.uuid, url: comment.url, text: comment.text}
|
||||
end
|
||||
end
|
||||
@@ -1,68 +0,0 @@
|
||||
defmodule MobilizonWeb.EventView do
|
||||
@moduledoc """
|
||||
View for Events
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.{EventView, ActorView, GroupView, AddressView}
|
||||
|
||||
def render("index.json", %{events: events, coord: coord, city: city, country: country}) do
|
||||
%{
|
||||
data: render_many(events, EventView, "event_simple.json"),
|
||||
coord: coord,
|
||||
city: city,
|
||||
country: country
|
||||
}
|
||||
end
|
||||
|
||||
def render("index_all.json", %{events: events}) do
|
||||
%{
|
||||
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_for_actor.json", %{event: event}) do
|
||||
%{id: event.id, title: event.title, uuid: event.uuid}
|
||||
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,
|
||||
uuid: event.uuid,
|
||||
organizer: %{
|
||||
username: event.organizer_actor.preferred_username,
|
||||
display_name: event.organizer_actor.name,
|
||||
avatar: event.organizer_actor.avatar_url
|
||||
},
|
||||
type: "Event",
|
||||
address_type: event.address_type
|
||||
}
|
||||
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,
|
||||
uuid: event.uuid,
|
||||
organizer: render_one(event.organizer_actor, ActorView, "actor_basic.json"),
|
||||
participants: render_many(event.participants, ActorView, "actor_basic.json"),
|
||||
physical_address: render_one(event.physical_address, AddressView, "address.json"),
|
||||
type: "Event",
|
||||
address_type: event.address_type
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
defmodule MobilizonWeb.ParticipantView do
|
||||
@moduledoc """
|
||||
View for Participants
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.ParticipantView
|
||||
|
||||
def render("index.json", %{participants: participants}) do
|
||||
%{data: render_many(participants, ParticipantView, "participant.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{participant: participant}) do
|
||||
%{data: render_one(participant, ParticipantView, "participant.json")}
|
||||
end
|
||||
|
||||
def render("participant.json", %{participant: participant}) do
|
||||
%{id: participant.id, role: participant.role}
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
defmodule MobilizonWeb.SearchView do
|
||||
@moduledoc """
|
||||
View for Events
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.{EventView, ActorView, GroupView, AddressView}
|
||||
|
||||
def render("search.json", %{events: events, actors: actors}) do
|
||||
%{
|
||||
data: %{
|
||||
events: render_many(events, EventView, "event_simple.json"),
|
||||
actors: render_many(actors, ActorView, "actor_basic.json")
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
defmodule MobilizonWeb.SessionView do
|
||||
@moduledoc """
|
||||
View for event Sessions
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.SessionView
|
||||
|
||||
def render("index.json", %{sessions: sessions}) do
|
||||
%{data: render_many(sessions, SessionView, "session.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{session: session}) do
|
||||
%{data: render_one(session, SessionView, "session.json")}
|
||||
end
|
||||
|
||||
def render("session.json", %{session: session}) do
|
||||
%{
|
||||
id: session.id,
|
||||
title: session.title,
|
||||
subtitle: session.subtitle,
|
||||
short_abstract: session.short_abstract,
|
||||
long_abstract: session.long_abstract,
|
||||
language: session.language,
|
||||
slides_url: session.slides_url,
|
||||
videos_urls: session.videos_urls,
|
||||
audios_urls: session.audios_urls
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
defmodule MobilizonWeb.TagView do
|
||||
@moduledoc """
|
||||
View for Tags
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.TagView
|
||||
|
||||
def render("index.json", %{tags: tags}) do
|
||||
%{data: render_many(tags, TagView, "tag.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{tag: tag}) do
|
||||
%{data: render_one(tag, TagView, "tag.json")}
|
||||
end
|
||||
|
||||
def render("tag.json", %{tag: tag}) do
|
||||
%{id: tag.id, title: tag.title}
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
defmodule MobilizonWeb.TrackView do
|
||||
@moduledoc """
|
||||
View for Tracks
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.TrackView
|
||||
|
||||
def render("index.json", %{tracks: tracks}) do
|
||||
%{data: render_many(tracks, TrackView, "track.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{track: track}) do
|
||||
%{data: render_one(track, TrackView, "track.json")}
|
||||
end
|
||||
|
||||
def render("track.json", %{track: track}) do
|
||||
%{id: track.id, name: track.name, description: track.description, color: track.color}
|
||||
end
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
defmodule MobilizonWeb.UserSessionView do
|
||||
@moduledoc """
|
||||
View for user Sessions
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
|
||||
def render("token.json", %{token: token, user: user}) do
|
||||
%{token: token, user: render_one(user, MobilizonWeb.UserView, "user_simple.json")}
|
||||
end
|
||||
end
|
||||
@@ -1,55 +0,0 @@
|
||||
defmodule MobilizonWeb.UserView do
|
||||
@moduledoc """
|
||||
View for Users
|
||||
"""
|
||||
use MobilizonWeb, :view
|
||||
alias MobilizonWeb.UserView
|
||||
alias MobilizonWeb.ActorView
|
||||
|
||||
def render("index.json", %{users: users}) do
|
||||
%{data: render_many(users, UserView, "user_simple.json")}
|
||||
end
|
||||
|
||||
def render("show.json", %{user: user}) do
|
||||
%{data: render_one(user, UserView, "user.json")}
|
||||
end
|
||||
|
||||
def render("show_simple.json", %{user: user}) do
|
||||
%{data: render_one(user, UserView, "user_simple.json")}
|
||||
end
|
||||
|
||||
def render("show_with_token.json", %{user: user, token: token}) do
|
||||
%{
|
||||
user: render_one(user, UserView, "user_simple.json"),
|
||||
token: token
|
||||
}
|
||||
end
|
||||
|
||||
def render("user_simple.json", %{user: user}) do
|
||||
%{
|
||||
id: user.id,
|
||||
role: user.role,
|
||||
actors: render_many(user.actors, ActorView, "actor_basic.json")
|
||||
}
|
||||
end
|
||||
|
||||
def render("user.json", %{user: user}) do
|
||||
%{id: user.id, role: user.role, actors: render_many(user.actors, ActorView, "actor.json")}
|
||||
end
|
||||
|
||||
def render("user_private.json", %{user: user}) do
|
||||
%{id: user.id, email: user.email, role: user.role}
|
||||
end
|
||||
|
||||
def render("confirmation.json", %{user: user}) do
|
||||
%{
|
||||
email: user.email
|
||||
}
|
||||
end
|
||||
|
||||
def render("password_reset.json", %{user: user}) do
|
||||
%{
|
||||
email: user.email
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user