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

@@ -32,6 +32,7 @@ defmodule Eventos.Groups.Group do
"""
use Ecto.Schema
import Ecto.Changeset
alias Eventos.Events.Event
alias Eventos.Groups.{Group, Member, Request}
alias Eventos.Accounts.Account
alias Eventos.Groups.Group.TitleSlug
@@ -43,7 +44,8 @@ defmodule Eventos.Groups.Group do
field :slug, TitleSlug.Type
field :uri, :string
field :url, :string
many_to_many :accounts, Account, join_through: Member
many_to_many :members, Account, join_through: Member
has_many :organized_events, Event, [foreign_key: :organizer_group_id]
has_many :requests, Request
timestamps()

View File

@@ -37,6 +37,14 @@ defmodule Eventos.Groups do
"""
def get_group!(id), do: Repo.get!(Group, id)
@doc """
Gets a single group, with all associations loaded.
"""
def get_group_full!(id) do
group = Repo.get!(Group, id)
Repo.preload(group, [:members, :organized_events])
end
@doc """
Creates a group.