check for slug uniqueness before submitting
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
This commit is contained in:
parent
c0afc96b8d
commit
50ecaee036
@ -1,6 +1,7 @@
|
||||
# v0.1.2
|
||||
- fix more typos
|
||||
- add to faq
|
||||
- check for slug uniqueness before submitting
|
||||
|
||||
# v0.1.1
|
||||
- improve search a whole lot
|
||||
|
@ -7,7 +7,7 @@ defmodule Memex.Contexts.Context do
|
||||
import Ecto.Changeset
|
||||
import MemexWeb.Gettext
|
||||
alias Ecto.{Changeset, UUID}
|
||||
alias Memex.Accounts.User
|
||||
alias Memex.{Accounts.User, Repo}
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@foreign_key_type :binary_id
|
||||
@ -49,6 +49,8 @@ defmodule Memex.Contexts.Context do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :content, :user_id, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
|
||||
@ -60,6 +62,8 @@ defmodule Memex.Contexts.Context do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :content, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
defp cast_tags_string(changeset, %{"tags_string" => tags_string})
|
||||
|
@ -6,7 +6,7 @@ defmodule Memex.Notes.Note do
|
||||
import Ecto.Changeset
|
||||
import MemexWeb.Gettext
|
||||
alias Ecto.{Changeset, UUID}
|
||||
alias Memex.Accounts.User
|
||||
alias Memex.{Accounts.User, Repo}
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@foreign_key_type :binary_id
|
||||
@ -48,6 +48,8 @@ defmodule Memex.Notes.Note do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :content, :user_id, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
|
||||
@ -59,6 +61,8 @@ defmodule Memex.Notes.Note do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :content, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
defp cast_tags_string(changeset, %{"tags_string" => tags_string})
|
||||
|
@ -6,7 +6,7 @@ defmodule Memex.Pipelines.Pipeline do
|
||||
import Ecto.Changeset
|
||||
import MemexWeb.Gettext
|
||||
alias Ecto.{Changeset, UUID}
|
||||
alias Memex.{Accounts.User, Pipelines.Steps.Step}
|
||||
alias Memex.{Accounts.User, Pipelines.Steps.Step, Repo}
|
||||
|
||||
@primary_key {:id, :binary_id, autogenerate: true}
|
||||
@foreign_key_type :binary_id
|
||||
@ -50,6 +50,8 @@ defmodule Memex.Pipelines.Pipeline do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :user_id, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
@spec update_changeset(t(), attrs :: map(), User.t()) :: changeset()
|
||||
@ -61,6 +63,8 @@ defmodule Memex.Pipelines.Pipeline do
|
||||
message: dgettext("errors", "invalid format: only numbers, letters and hyphen are accepted")
|
||||
)
|
||||
|> validate_required([:slug, :visibility])
|
||||
|> unique_constraint(:slug)
|
||||
|> unsafe_validate_unique(:slug, Repo)
|
||||
end
|
||||
|
||||
defp cast_tags_string(changeset, %{"tags_string" => tags_string})
|
||||
|
@ -103,11 +103,11 @@ msgid "oops, something went wrong! Please check the errors below"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex/contexts/context.ex:49
|
||||
#: lib/memex/contexts/context.ex:60
|
||||
#: lib/memex/contexts/context.ex:62
|
||||
#: lib/memex/notes/note.ex:48
|
||||
#: lib/memex/notes/note.ex:59
|
||||
#: lib/memex/notes/note.ex:61
|
||||
#: lib/memex/pipelines/pipeline.ex:50
|
||||
#: lib/memex/pipelines/pipeline.ex:61
|
||||
#: lib/memex/pipelines/pipeline.ex:63
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "invalid format: only numbers, letters and hyphen are accepted"
|
||||
msgstr ""
|
||||
|
@ -102,11 +102,11 @@ msgid "oops, something went wrong! Please check the errors below"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex/contexts/context.ex:49
|
||||
#: lib/memex/contexts/context.ex:60
|
||||
#: lib/memex/contexts/context.ex:62
|
||||
#: lib/memex/notes/note.ex:48
|
||||
#: lib/memex/notes/note.ex:59
|
||||
#: lib/memex/notes/note.ex:61
|
||||
#: lib/memex/pipelines/pipeline.ex:50
|
||||
#: lib/memex/pipelines/pipeline.ex:61
|
||||
#: lib/memex/pipelines/pipeline.ex:63
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "invalid format: only numbers, letters and hyphen are accepted"
|
||||
msgstr ""
|
||||
|
Loading…
Reference in New Issue
Block a user