Filter out cancelled events on homepage

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-12-18 16:43:31 +01:00
parent ad0086032b
commit 766b452640
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -364,6 +364,7 @@ defmodule Mobilizon.Events do
|> filter_future_events(is_future) |> filter_future_events(is_future)
|> filter_public_visibility() |> filter_public_visibility()
|> filter_draft() |> filter_draft()
|> filter_cancelled_events()
|> filter_local_or_from_followed_instances_events() |> filter_local_or_from_followed_instances_events()
|> Page.build_page(page, limit) |> Page.build_page(page, limit)
end end
@ -1655,6 +1656,15 @@ defmodule Mobilizon.Events do
from(e in query, where: e.draft == ^is_draft) from(e in query, where: e.draft == ^is_draft)
end end
@spec filter_cancelled_events(Ecto.Query.t(), boolean()) :: Ecto.Query.t()
defp filter_cancelled_events(query, hide_cancelled \\ true)
defp filter_cancelled_events(query, false), do: query
defp filter_cancelled_events(query, true) do
from(e in query, where: e.status != ^:cancelled)
end
@spec filter_future_events(Ecto.Query.t(), boolean) :: Ecto.Query.t() @spec filter_future_events(Ecto.Query.t(), boolean) :: Ecto.Query.t()
defp filter_future_events(query, true) do defp filter_future_events(query, true) do
from(q in query, from(q in query,