2018-07-09 14:19:24 +02:00
|
|
|
defmodule EventosWeb.ParticipantController do
|
|
|
|
@moduledoc """
|
|
|
|
Controller for participants to an event
|
|
|
|
"""
|
|
|
|
use EventosWeb, :controller
|
|
|
|
|
|
|
|
alias Eventos.Events
|
|
|
|
|
|
|
|
def join(conn, %{"uuid" => uuid}) do
|
|
|
|
with event <- Events.get_event_by_uuid(uuid),
|
2018-07-27 10:45:35 +02:00
|
|
|
%{actor: actor} <- Guardian.Plug.current_resource(conn) do
|
|
|
|
participant =
|
|
|
|
Events.create_participant(%{"event_id" => event.id, "actor_id" => actor.id, "role" => 1})
|
|
|
|
|
|
|
|
render(conn, "participant.json", %{participant: participant})
|
2018-07-09 14:19:24 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|