Encore des commits degeu

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-06-06 17:42:53 +02:00
parent 90de5a105b
commit 63b63d9ee2
31 changed files with 3200 additions and 2937 deletions

View File

@@ -77,6 +77,13 @@ defmodule Eventos.Events do
Repo.get_by(Event, url: url)
end
@doc """
Gets an event by it's UUID
"""
def get_event_by_uuid(uuid) do
Repo.get_by(Event, uuid: uuid)
end
@doc """
Gets a single event, with all associations loaded.
"""
@@ -93,6 +100,14 @@ defmodule Eventos.Events do
Repo.preload(event, [:organizer_actor, :category, :sessions, :tracks, :tags, :participants, :address])
end
@doc """
Gets a full event by it's UUID
"""
def get_event_full_by_uuid(uuid) do
event = Repo.get_by(Event, uuid: uuid)
Repo.preload(event, [:organizer_actor, :category, :sessions, :tracks, :tags, :participants, :address])
end
@spec get_event_full_by_name_and_slug!(String.t, String.t) :: Event.t
def get_event_full_by_name_and_slug!(name, slug) do
query = case String.split(name, "@") do
@@ -139,7 +154,8 @@ defmodule Eventos.Events do
def create_event(attrs \\ %{}) do
%Event{}
|> Event.changeset(attrs)
|> Repo.insert()
|> Repo.insert!()
|> Repo.preload([:organizer_actor])
end
@doc """