feat(back): add admin setting to disable external event feature
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
af670f3947
commit
f6611e8eb5
|
@ -41,7 +41,10 @@ config :mobilizon, :instance,
|
||||||
email_reply_to: "noreply@localhost"
|
email_reply_to: "noreply@localhost"
|
||||||
|
|
||||||
config :mobilizon, :groups, enabled: true
|
config :mobilizon, :groups, enabled: true
|
||||||
config :mobilizon, :events, creation: true
|
|
||||||
|
config :mobilizon, :events,
|
||||||
|
creation: true,
|
||||||
|
external: true
|
||||||
|
|
||||||
config :mobilizon, :restrictions, only_admin_can_create_groups: false
|
config :mobilizon, :restrictions, only_admin_can_create_groups: false
|
||||||
config :mobilizon, :restrictions, only_groups_can_create_events: false
|
config :mobilizon, :restrictions, only_groups_can_create_events: false
|
||||||
|
|
|
@ -72,6 +72,7 @@ export const CONFIG = gql`
|
||||||
features {
|
features {
|
||||||
groups
|
groups
|
||||||
eventCreation
|
eventCreation
|
||||||
|
eventExternal
|
||||||
antispam
|
antispam
|
||||||
}
|
}
|
||||||
restrictions {
|
restrictions {
|
||||||
|
@ -370,6 +371,7 @@ export const FEATURES = gql`
|
||||||
features {
|
features {
|
||||||
groups
|
groups
|
||||||
eventCreation
|
eventCreation
|
||||||
|
eventExternal
|
||||||
antispam
|
antispam
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ export interface IConfig {
|
||||||
timezones: string[];
|
timezones: string[];
|
||||||
features: {
|
features: {
|
||||||
eventCreation: boolean;
|
eventCreation: boolean;
|
||||||
|
eventExternal: boolean;
|
||||||
groups: boolean;
|
groups: boolean;
|
||||||
antispam: boolean;
|
antispam: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -246,7 +246,10 @@
|
||||||
</o-radio>
|
</o-radio>
|
||||||
</div>-->
|
</div>-->
|
||||||
|
|
||||||
<o-field :label="t('External registration')">
|
<o-field
|
||||||
|
:label="t('External registration')"
|
||||||
|
v-if="features?.eventExternal"
|
||||||
|
>
|
||||||
<o-switch v-model="externalParticipation">
|
<o-switch v-model="externalParticipation">
|
||||||
{{
|
{{
|
||||||
t("I want to manage the registration with an external provider")
|
t("I want to manage the registration with an external provider")
|
||||||
|
@ -260,6 +263,7 @@
|
||||||
type="url"
|
type="url"
|
||||||
v-model="event.externalParticipationUrl"
|
v-model="event.externalParticipationUrl"
|
||||||
:placeholder="t('External provider URL')"
|
:placeholder="t('External provider URL')"
|
||||||
|
required
|
||||||
/>
|
/>
|
||||||
</o-field>
|
</o-field>
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
|
||||||
features: %{
|
features: %{
|
||||||
groups: Config.instance_group_feature_enabled?(),
|
groups: Config.instance_group_feature_enabled?(),
|
||||||
event_creation: Config.instance_event_creation_enabled?(),
|
event_creation: Config.instance_event_creation_enabled?(),
|
||||||
|
event_external: Config.instance_event_external_enabled?(),
|
||||||
antispam: AntiSpam.service().ready?()
|
antispam: AntiSpam.service().ready?()
|
||||||
},
|
},
|
||||||
restrictions: %{
|
restrictions: %{
|
||||||
|
|
|
@ -254,6 +254,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
|
|
||||||
with {:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
with {:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
||||||
{:can_create_event, true} <- can_create_event(args),
|
{:can_create_event, true} <- can_create_event(args),
|
||||||
|
{:event_external, true} <- edit_event_external_checker(args),
|
||||||
{:organizer_group_member, true} <-
|
{:organizer_group_member, true} <-
|
||||||
{:organizer_group_member, is_organizer_group_member?(args)},
|
{:organizer_group_member, is_organizer_group_member?(args)},
|
||||||
args_with_organizer <-
|
args_with_organizer <-
|
||||||
|
@ -281,6 +282,13 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
"Only groups can create events"
|
"Only groups can create events"
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{:event_external, false} ->
|
||||||
|
{:error,
|
||||||
|
dgettext(
|
||||||
|
"errors",
|
||||||
|
"Providing external registration is not allowed"
|
||||||
|
)}
|
||||||
|
|
||||||
{:organizer_group_member, false} ->
|
{:organizer_group_member, false} ->
|
||||||
{:error,
|
{:error,
|
||||||
dgettext(
|
dgettext(
|
||||||
|
@ -322,6 +330,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec edit_event_external_checker(map()) :: {:event_external, boolean()}
|
||||||
|
defp edit_event_external_checker(args) do
|
||||||
|
if Config.instance_event_external_enabled?() do
|
||||||
|
{:event_external, true}
|
||||||
|
else
|
||||||
|
{:event_external,
|
||||||
|
Map.get(args, :join_options) != :external and
|
||||||
|
is_nil(Map.get(args, :external_participation_url))}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Update an event
|
Update an event
|
||||||
"""
|
"""
|
||||||
|
@ -340,6 +359,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
args <- extract_timezone(args, user.id),
|
args <- extract_timezone(args, user.id),
|
||||||
{:event_can_be_managed, true} <-
|
{:event_can_be_managed, true} <-
|
||||||
{:event_can_be_managed, can_event_be_updated_by?(event, actor)},
|
{:event_can_be_managed, can_event_be_updated_by?(event, actor)},
|
||||||
|
{:event_external, true} <- edit_event_external_checker(args),
|
||||||
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
{:ok, %Activity{data: %{"object" => %{"type" => "Event"}}}, %Event{} = event} <-
|
||||||
API.Events.update_event(args, event) do
|
API.Events.update_event(args, event) do
|
||||||
{:ok, event}
|
{:ok, event}
|
||||||
|
@ -351,6 +371,13 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
||||||
"This profile doesn't have permission to update an event on behalf of this group"
|
"This profile doesn't have permission to update an event on behalf of this group"
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{:event_external, false} ->
|
||||||
|
{:error,
|
||||||
|
dgettext(
|
||||||
|
"errors",
|
||||||
|
"Providing external registration is not allowed"
|
||||||
|
)}
|
||||||
|
|
||||||
{:error, :event_not_found} ->
|
{:error, :event_not_found} ->
|
||||||
{:error, dgettext("errors", "Event not found")}
|
{:error, dgettext("errors", "Event not found")}
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,10 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
|
||||||
description: "Whether event creation is allowed on this instance"
|
description: "Whether event creation is allowed on this instance"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
field(:event_external, :boolean,
|
||||||
|
description: "Whether redirecting to external providers is authorized in event edition"
|
||||||
|
)
|
||||||
|
|
||||||
field(:antispam, :boolean, description: "Whether anti-spam is activated on this instance")
|
field(:antispam, :boolean, description: "Whether anti-spam is activated on this instance")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -357,6 +357,10 @@ defmodule Mobilizon.Config do
|
||||||
def instance_event_creation_enabled?,
|
def instance_event_creation_enabled?,
|
||||||
do: :mobilizon |> Application.get_env(:events) |> Keyword.get(:creation)
|
do: :mobilizon |> Application.get_env(:events) |> Keyword.get(:creation)
|
||||||
|
|
||||||
|
@spec instance_event_external_enabled? :: boolean
|
||||||
|
def instance_event_external_enabled?,
|
||||||
|
do: :mobilizon |> Application.get_env(:events) |> Keyword.get(:external)
|
||||||
|
|
||||||
@spec instance_export_formats :: %{event_participants: list(String.t())}
|
@spec instance_export_formats :: %{event_participants: list(String.t())}
|
||||||
def instance_export_formats do
|
def instance_export_formats do
|
||||||
%{
|
%{
|
||||||
|
|
Loading…
Reference in a new issue