all developments of milestone 1

This commit is contained in:
setop
2024-04-10 12:36:21 +00:00
parent a78dc261e5
commit 7030d56864
266 changed files with 5391 additions and 2609 deletions

View File

@@ -25,6 +25,7 @@ defmodule Mobilizon.Events.EventOptions do
show_participation_price: boolean,
offers: [EventOffer.t()],
participation_condition: [EventParticipationCondition.t()],
hide_number_of_participants: boolean,
show_start_time: boolean,
show_end_time: boolean,
timezone: String.t() | nil,
@@ -41,6 +42,7 @@ defmodule Mobilizon.Events.EventOptions do
:program,
:comment_moderation,
:show_participation_price,
:hide_number_of_participants,
:show_start_time,
:show_end_time,
:timezone,
@@ -59,6 +61,7 @@ defmodule Mobilizon.Events.EventOptions do
field(:program, :string)
field(:comment_moderation, CommentModeration)
field(:show_participation_price, :boolean)
field(:hide_number_of_participants, :boolean, default: false)
field(:show_start_time, :boolean, default: true)
field(:show_end_time, :boolean, default: true)
field(:timezone, :string)

View File

@@ -16,6 +16,7 @@ defmodule Mobilizon.Events do
alias Mobilizon.Actors.{Actor, Follower}
alias Mobilizon.Addresses.Address
alias Mobilizon.Config
alias Mobilizon.Events.{
Event,
@@ -571,6 +572,7 @@ defmodule Mobilizon.Events do
|> events_for_search_query()
|> events_for_begins_on(Map.get(args, :begins_on, DateTime.utc_now()))
|> events_for_ends_on(Map.get(args, :ends_on))
|> events_for_longevents(args)
|> events_for_category(args)
|> events_for_categories(args)
|> events_for_languages(args)
@@ -1377,6 +1379,38 @@ defmodule Mobilizon.Events do
end
end
@spec events_for_longevents(Ecto.Queryable.t(), map()) :: Ecto.Query.t()
defp events_for_longevents(query, args) do
duration = Config.get([:instance, :duration_of_long_event], 0)
if duration <= 0 do
query
else
longevents = Map.get(args, :longevents)
case longevents do
nil ->
query
true ->
where(
query,
[q],
not is_nil(q.ends_on) and
q.ends_on > fragment("? + '1 days'::interval * ?", q.begins_on, ^duration)
)
false ->
where(
query,
[q],
is_nil(q.ends_on) or
q.ends_on <= fragment("? + '1 days'::interval * ?", q.begins_on, ^duration)
)
end
end
end
@spec events_for_category(Ecto.Queryable.t(), map()) :: Ecto.Query.t()
defp events_for_category(query, %{category: category}) when is_valid_string(category) do
where(query, [q], q.category == ^category)