Improve and activate groups

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-09-29 09:53:48 +02:00
parent 1ca46a6863
commit 49a5725da3
131 changed files with 16440 additions and 1929 deletions

View File

@@ -1579,7 +1579,8 @@ defmodule Mobilizon.Actors do
:comments,
:attributed_to,
:tags,
:physical_address
:physical_address,
:contacts
])
ActivityPub.delete(event, actor, false)

View File

@@ -99,11 +99,11 @@ defmodule Mobilizon.Config do
)
)
@spec instance_registrations_whitelist :: list(String.t())
def instance_registrations_whitelist, do: instance_config()[:registration_email_whitelist]
@spec instance_registrations_allowlist :: list(String.t())
def instance_registrations_allowlist, do: instance_config()[:registration_email_allowlist]
@spec instance_registrations_whitelist? :: boolean
def instance_registrations_whitelist?, do: length(instance_registrations_whitelist()) > 0
@spec instance_registrations_allowlist? :: boolean
def instance_registrations_allowlist?, do: length(instance_registrations_allowlist()) > 0
@spec instance_demo_mode? :: boolean
def instance_demo_mode?, do: to_boolean(instance_config()[:demo])

View File

@@ -59,7 +59,8 @@ defmodule Mobilizon.Events.Event do
sessions: [Session.t()],
mentions: [Mention.t()],
tags: [Tag.t()],
participants: [Actor.t()]
participants: [Actor.t()],
contacts: [Actor.t()]
}
@update_required_attrs [:title, :begins_on, :organizer_actor_id]
@@ -114,6 +115,7 @@ defmodule Mobilizon.Events.Event do
has_many(:sessions, Session)
has_many(:mentions, Mention)
has_many(:comments, Comment)
many_to_many(:contacts, Actor, join_through: "event_contacts", on_replace: :delete)
many_to_many(:tags, Tag, join_through: "events_tags", on_replace: :delete)
many_to_many(:participants, Actor, join_through: Participant)
@@ -147,6 +149,7 @@ defmodule Mobilizon.Events.Event do
defp common_changeset(%Changeset{} = changeset, attrs) do
changeset
|> cast_embed(:options)
|> put_assoc(:contacts, Map.get(attrs, :contacts, []))
|> put_tags(attrs)
|> put_address(attrs)
|> put_picture(attrs)

View File

@@ -83,7 +83,8 @@ defmodule Mobilizon.Events do
:comments,
:participants,
:physical_address,
:picture
:picture,
:contacts
]
@doc """
@@ -1019,7 +1020,7 @@ defmodule Mobilizon.Events do
) do
with {:update_event_participation_stats, true} <-
{:update_event_participation_stats, update_event_participation_stats},
{:ok, %Event{} = event} <- get_event(event_id),
{:ok, %Event{} = event} <- get_event_with_preload(event_id),
%EventParticipantStats{} = participant_stats <-
Map.get(event, :participant_stats),
%EventParticipantStats{} = participant_stats <-

View File

@@ -12,6 +12,7 @@ defmodule Mobilizon.Users.User do
alias Mobilizon.Events.FeedToken
alias Mobilizon.Users.{Setting, UserRole}
alias Mobilizon.Web.Email.Checker
import Mobilizon.Web.Gettext
@type t :: %__MODULE__{
email: String.t(),
@@ -100,9 +101,13 @@ defmodule Mobilizon.Users.User do
user
|> cast(attrs, @attrs)
|> validate_required(@required_attrs)
|> unique_constraint(:email, message: "This email is already used.")
|> unique_constraint(:email, message: dgettext("errors", "This email is already used."))
|> Checker.validate_changeset()
|> validate_length(:password, min: 6, max: 200, message: "The chosen password is too short.")
|> validate_length(:password,
min: 6,
max: 200,
message: dgettext("errors", "The chosen password is too short.")
)
if Map.has_key?(attrs, :default_actor) do
put_assoc(changeset, :default_actor, attrs.default_actor)
@@ -129,7 +134,11 @@ defmodule Mobilizon.Users.User do
|> save_confirmation_token()
|> unique_constraint(
:confirmation_token,
message: "The registration token is already in use, this looks like an issue on our side."
message:
dgettext(
"errors",
"The registration token is already in use, this looks like an issue on our side."
)
)
end