mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-24 08:54:08 +00:00
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
8 changed files with 48 additions and 2 deletions
|
@ -41,7 +41,10 @@ config :mobilizon, :instance,
|
|||
email_reply_to: "noreply@localhost"
|
||||
|
||||
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_groups_can_create_events: false
|
||||
|
|
|
@ -72,6 +72,7 @@ export const CONFIG = gql`
|
|||
features {
|
||||
groups
|
||||
eventCreation
|
||||
eventExternal
|
||||
antispam
|
||||
}
|
||||
restrictions {
|
||||
|
@ -370,6 +371,7 @@ export const FEATURES = gql`
|
|||
features {
|
||||
groups
|
||||
eventCreation
|
||||
eventExternal
|
||||
antispam
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ export interface IConfig {
|
|||
timezones: string[];
|
||||
features: {
|
||||
eventCreation: boolean;
|
||||
eventExternal: boolean;
|
||||
groups: boolean;
|
||||
antispam: boolean;
|
||||
};
|
||||
|
|
|
@ -246,7 +246,10 @@
|
|||
</o-radio>
|
||||
</div>-->
|
||||
|
||||
<o-field :label="t('External registration')">
|
||||
<o-field
|
||||
:label="t('External registration')"
|
||||
v-if="features?.eventExternal"
|
||||
>
|
||||
<o-switch v-model="externalParticipation">
|
||||
{{
|
||||
t("I want to manage the registration with an external provider")
|
||||
|
@ -260,6 +263,7 @@
|
|||
type="url"
|
||||
v-model="event.externalParticipationUrl"
|
||||
:placeholder="t('External provider URL')"
|
||||
required
|
||||
/>
|
||||
</o-field>
|
||||
|
||||
|
|
|
@ -145,6 +145,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
|
|||
features: %{
|
||||
groups: Config.instance_group_feature_enabled?(),
|
||||
event_creation: Config.instance_event_creation_enabled?(),
|
||||
event_external: Config.instance_event_external_enabled?(),
|
||||
antispam: AntiSpam.service().ready?()
|
||||
},
|
||||
restrictions: %{
|
||||
|
|
|
@ -254,6 +254,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||
|
||||
with {:is_owned, %Actor{} = organizer_actor} <- User.owns_actor(user, organizer_actor_id),
|
||||
{:can_create_event, true} <- can_create_event(args),
|
||||
{:event_external, true} <- edit_event_external_checker(args),
|
||||
{:organizer_group_member, true} <-
|
||||
{:organizer_group_member, is_organizer_group_member?(args)},
|
||||
args_with_organizer <-
|
||||
|
@ -281,6 +282,13 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||
"Only groups can create events"
|
||||
)}
|
||||
|
||||
{:event_external, false} ->
|
||||
{:error,
|
||||
dgettext(
|
||||
"errors",
|
||||
"Providing external registration is not allowed"
|
||||
)}
|
||||
|
||||
{:organizer_group_member, false} ->
|
||||
{:error,
|
||||
dgettext(
|
||||
|
@ -322,6 +330,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||
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 """
|
||||
Update an event
|
||||
"""
|
||||
|
@ -340,6 +359,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||
args <- extract_timezone(args, user.id),
|
||||
{:event_can_be_managed, true} <-
|
||||
{: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} <-
|
||||
API.Events.update_event(args, event) do
|
||||
{: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"
|
||||
)}
|
||||
|
||||
{:event_external, false} ->
|
||||
{:error,
|
||||
dgettext(
|
||||
"errors",
|
||||
"Providing external registration is not allowed"
|
||||
)}
|
||||
|
||||
{:error, :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"
|
||||
)
|
||||
|
||||
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")
|
||||
end
|
||||
|
||||
|
|
|
@ -357,6 +357,10 @@ defmodule Mobilizon.Config do
|
|||
def instance_event_creation_enabled?,
|
||||
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())}
|
||||
def instance_export_formats do
|
||||
%{
|
||||
|
|
Loading…
Reference in a new issue