Merge branch 'bug/move-sql-columns-from-varchar-to-text' into 'master'
Handle fields limitation better Closes #226, #225 et #239 See merge request framasoft/mobilizon!288
This commit is contained in:
commit
0a1270b73a
@ -39,6 +39,8 @@ export default {
|
||||
:allow-new="true"
|
||||
:field="path"
|
||||
icon="label"
|
||||
maxlength="20"
|
||||
maxtags="10"
|
||||
:placeholder="$t('Eg: Stockholm, Dance, Chess…')"
|
||||
@typing="getFilteredTags"
|
||||
>
|
||||
|
@ -125,6 +125,7 @@ defmodule Mobilizon.Events.Event do
|
||||
|> cast(attrs, @attrs)
|
||||
|> cast_embed(:options)
|
||||
|> validate_required(@required_attrs)
|
||||
|> validate_lengths()
|
||||
end
|
||||
|
||||
@doc false
|
||||
@ -135,6 +136,18 @@ defmodule Mobilizon.Events.Event do
|
||||
|> cast_embed(:options)
|
||||
|> put_tags(attrs)
|
||||
|> validate_required(@update_required_attrs)
|
||||
|> validate_lengths()
|
||||
end
|
||||
|
||||
@spec validate_lengths(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||
defp validate_lengths(%Ecto.Changeset{} = changeset) do
|
||||
changeset
|
||||
|> validate_length(:title, min: 3, max: 200)
|
||||
|> validate_length(:online_address, min: 3, max: 2000)
|
||||
|> validate_length(:phone_address, min: 3, max: 200)
|
||||
|> validate_length(:category, min: 2, max: 100)
|
||||
# |> validate_length(:category, min: 2, max: 100)
|
||||
|> validate_length(:slug, min: 3, max: 200)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
@ -36,5 +36,7 @@ defmodule Mobilizon.Events.Tag do
|
||||
|> TitleSlug.maybe_generate_slug()
|
||||
|> validate_required(@required_attrs)
|
||||
|> TitleSlug.unique_constraint()
|
||||
|> validate_length(:title, min: 2, max: 20)
|
||||
|> validate_length(:slug, min: 2, max: 20)
|
||||
end
|
||||
end
|
||||
|
@ -79,7 +79,7 @@ defmodule Mobilizon.Users.User do
|
||||
|> validate_required(@required_attrs)
|
||||
|> unique_constraint(:email, message: "This email is already used.")
|
||||
|> validate_email()
|
||||
|> validate_length(:password, min: 6, max: 100, message: "The chosen password is too short.")
|
||||
|> validate_length(:password, min: 6, max: 200, message: "The chosen password is too short.")
|
||||
|
||||
if Map.has_key?(attrs, :default_actor) do
|
||||
put_assoc(changeset, :default_actor, attrs.default_actor)
|
||||
@ -130,7 +130,7 @@ defmodule Mobilizon.Users.User do
|
||||
|> cast(attrs, required_attrs)
|
||||
|> validate_length(:password,
|
||||
min: 6,
|
||||
max: 100,
|
||||
max: 200,
|
||||
message: "registration.error.password_too_short"
|
||||
)
|
||||
|> hash_password()
|
||||
@ -154,7 +154,7 @@ defmodule Mobilizon.Users.User do
|
||||
end
|
||||
|
||||
@spec save_confirmation_token(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||
defp save_confirmation_token(changeset) do
|
||||
defp save_confirmation_token(%Ecto.Changeset{} = changeset) do
|
||||
case changeset do
|
||||
%Ecto.Changeset{valid?: true, changes: %{email: _email}} ->
|
||||
now = DateTime.utc_now()
|
||||
@ -169,7 +169,9 @@ defmodule Mobilizon.Users.User do
|
||||
end
|
||||
|
||||
@spec validate_email(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||
defp validate_email(changeset) do
|
||||
defp validate_email(%Ecto.Changeset{} = changeset) do
|
||||
changeset = validate_length(changeset, :email, min: 3, max: 250)
|
||||
|
||||
case changeset do
|
||||
%Ecto.Changeset{valid?: true, changes: %{email: email}} ->
|
||||
case EmailChecker.valid?(email) do
|
||||
@ -186,7 +188,7 @@ defmodule Mobilizon.Users.User do
|
||||
end
|
||||
|
||||
@spec hash_password(Ecto.Changeset.t()) :: Ecto.Changeset.t()
|
||||
defp hash_password(changeset) do
|
||||
defp hash_password(%Ecto.Changeset{} = changeset) do
|
||||
case changeset do
|
||||
%Ecto.Changeset{valid?: true, changes: %{password: password}} ->
|
||||
put_change(changeset, :password_hash, Argon2.hash_pwd_salt(password))
|
||||
|
@ -0,0 +1,81 @@
|
||||
defmodule Mobilizon.Storage.Repo.Migrations.MoveSQLColumnsFromVarCharToText do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:events) do
|
||||
modify(:title, :text, null: false)
|
||||
modify(:online_address, :text, null: true)
|
||||
modify(:phone_address, :text, null: true)
|
||||
modify(:category, :text, null: true)
|
||||
modify(:slug, :text, null: true)
|
||||
end
|
||||
|
||||
alter table(:addresses) do
|
||||
modify(:description, :text, null: true)
|
||||
modify(:street, :text, null: true)
|
||||
end
|
||||
|
||||
alter table(:bots) do
|
||||
modify(:source, :text, null: false)
|
||||
end
|
||||
|
||||
alter table(:report_notes) do
|
||||
modify(:content, :text, null: false)
|
||||
end
|
||||
|
||||
alter table(:reports) do
|
||||
modify(:content, :text, null: true)
|
||||
end
|
||||
|
||||
alter table(:sessions) do
|
||||
modify(:title, :text, null: false)
|
||||
modify(:subtitle, :text, null: true)
|
||||
modify(:slides_url, :text, null: true)
|
||||
modify(:videos_urls, :text, null: true)
|
||||
modify(:audios_urls, :text, null: true)
|
||||
end
|
||||
|
||||
alter table(:tracks) do
|
||||
modify(:name, :text, null: false)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:events) do
|
||||
modify(:title, :string, null: false)
|
||||
modify(:online_address, :string, null: true)
|
||||
modify(:phone_address, :string, null: true)
|
||||
modify(:category, :string, null: true)
|
||||
modify(:slug, :string, null: true)
|
||||
end
|
||||
|
||||
alter table(:addresses) do
|
||||
modify(:description, :string, null: true)
|
||||
modify(:street, :string, null: true)
|
||||
end
|
||||
|
||||
alter table(:bots) do
|
||||
modify(:source, :string, null: false)
|
||||
end
|
||||
|
||||
alter table(:report_notes) do
|
||||
modify(:content, :string, null: false)
|
||||
end
|
||||
|
||||
alter table(:reports) do
|
||||
modify(:content, :string, null: true)
|
||||
end
|
||||
|
||||
alter table(:sessions) do
|
||||
modify(:title, :string, null: false)
|
||||
modify(:subtitle, :string, null: true)
|
||||
modify(:slides_url, :string, null: true)
|
||||
modify(:videos_urls, :string, null: true)
|
||||
modify(:audios_urls, :string, null: true)
|
||||
end
|
||||
|
||||
alter table(:tracks) do
|
||||
modify(:name, :string, null: false)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user