Browse Source

Filter out cancelled events on homepage

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
honeypot-register-form
Thomas Citharel 1 month ago
parent
commit
766b452640
No known key found for this signature in database GPG Key ID: A061B9DDE0CA0773
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      lib/mobilizon/events/events.ex

+ 10
- 0
lib/mobilizon/events/events.ex View File

@ -364,6 +364,7 @@ defmodule Mobilizon.Events do
|> filter_future_events(is_future)
|> filter_public_visibility()
|> filter_draft()
|> filter_cancelled_events()
|> filter_local_or_from_followed_instances_events()
|> Page.build_page(page, limit)
end
@ -1655,6 +1656,15 @@ defmodule Mobilizon.Events do
from(e in query, where: e.draft == ^is_draft)
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()
defp filter_future_events(query, true) do
from(q in query,


Loading…
Cancel
Save