improve changesets and typespecs

This commit is contained in:
shibao 2022-11-23 20:46:41 -05:00
parent 20a2311229
commit e0ac714681
38 changed files with 191 additions and 189 deletions

View File

@ -1,3 +1,6 @@
# v0.7.2
- Code improvements
# v0.7.1
- Fix table component alignment and styling
- Fix toggle button styling

View File

@ -17,8 +17,8 @@ If you're multilingual, this project can use your translations! Visit
functions as short as possible while keeping variable names descriptive! For
instance, use inline `do:` blocks for short functions and make your aliases as
short as possible without introducing ambiguity.
- I.e. since there's only one `Changeset` in the app, please alias
`Changeset.t(Type.t())` instead of using `Ecto.Changeset.t(Long.Type.t())`
- I.e. since there's only one `AmmoGroup` in the app, please alias
`AmmoGroup.t()` instead of using `Cannery.Ammo.AmmoGroup.t()`
- Use pipelines when possible. If only calling a single method, a pipeline isn't
strictly necessary but still encouraged for future modification.
- Please add typespecs to your functions! Even your private functions may be

View File

@ -23,7 +23,7 @@ defmodule Cannery.Accounts do
nil
"""
@spec get_user_by_email(String.t()) :: User.t() | nil
@spec get_user_by_email(email :: String.t()) :: User.t() | nil
def get_user_by_email(email) when is_binary(email), do: Repo.get_by(User, email: email)
@doc """
@ -38,7 +38,7 @@ defmodule Cannery.Accounts do
nil
"""
@spec get_user_by_email_and_password(String.t(), String.t()) ::
@spec get_user_by_email_and_password(email :: String.t(), password :: String.t()) ::
User.t() | nil
def get_user_by_email_and_password(email, password)
when is_binary(email) and is_binary(password) do
@ -86,7 +86,7 @@ defmodule Cannery.Accounts do
[%User{}]
"""
@spec list_users_by_role(:admin | :user) :: [User.t()]
@spec list_users_by_role(User.role()) :: [User.t()]
def list_users_by_role(role) do
role = role |> to_string()
Repo.all(from u in User, where: u.role == ^role, order_by: u.email)
@ -106,15 +106,21 @@ defmodule Cannery.Accounts do
{:error, %Changeset{}}
"""
@spec register_user(map()) :: {:ok, User.t()} | {:error, Changeset.t(User.new_user())}
@spec register_user(attrs :: map()) :: {:ok, User.t()} | {:error, User.changeset()}
def register_user(attrs) do
Multi.new()
|> Multi.one(:users_count, from(u in User, select: count(u.id), distinct: true))
|> Multi.insert(:add_user, fn %{users_count: count} ->
# if no registered users, make first user an admin
role =
if Repo.one!(from u in User, select: count(u.id), distinct: true) == 0,
do: "admin",
else: "user"
role = if count == 0, do: "admin", else: "user"
%User{} |> User.registration_changeset(attrs |> Map.put("role", role)) |> Repo.insert()
User.registration_changeset(attrs) |> User.role_changeset(role)
end)
|> Repo.transaction()
|> case do
{:ok, %{add_user: user}} -> {:ok, user}
{:error, :add_user, changeset, _changes_so_far} -> {:error, changeset}
end
end
@doc """
@ -126,12 +132,10 @@ defmodule Cannery.Accounts do
%Changeset{data: %User{}}
"""
@spec change_user_registration(User.t() | User.new_user()) ::
Changeset.t(User.t() | User.new_user())
@spec change_user_registration(User.t() | User.new_user(), map()) ::
Changeset.t(User.t() | User.new_user())
def change_user_registration(user, attrs \\ %{}),
do: User.registration_changeset(user, attrs, hash_password: false)
@spec change_user_registration() :: User.changeset()
@spec change_user_registration(attrs :: map()) :: User.changeset()
def change_user_registration(attrs \\ %{}),
do: User.registration_changeset(attrs, hash_password: false)
## Settings
@ -144,7 +148,8 @@ defmodule Cannery.Accounts do
%Changeset{data: %User{}}
"""
@spec change_user_email(User.t(), map()) :: Changeset.t(User.t())
@spec change_user_email(User.t()) :: User.changeset()
@spec change_user_email(User.t(), attrs :: map()) :: User.changeset()
def change_user_email(user, attrs \\ %{}), do: User.email_changeset(user, attrs)
@doc """
@ -156,7 +161,7 @@ defmodule Cannery.Accounts do
%Changeset{data: %User{}}
"""
@spec change_user_role(User.t(), atom()) :: Changeset.t(User.t())
@spec change_user_role(User.t(), User.role()) :: User.changeset()
def change_user_role(user, role), do: User.role_changeset(user, role)
@doc """
@ -172,8 +177,8 @@ defmodule Cannery.Accounts do
{:error, %Changeset{}}
"""
@spec apply_user_email(User.t(), String.t(), map()) ::
{:ok, User.t()} | {:error, Changeset.t(User.t())}
@spec apply_user_email(User.t(), email :: String.t(), attrs :: map()) ::
{:ok, User.t()} | {:error, User.changeset()}
def apply_user_email(user, password, attrs) do
user
|> User.email_changeset(attrs)
@ -187,7 +192,7 @@ defmodule Cannery.Accounts do
If the token matches, the user email is updated and the token is deleted.
The confirmed_at date is also updated to the current time.
"""
@spec update_user_email(User.t(), String.t()) :: :ok | :error
@spec update_user_email(User.t(), token :: String.t()) :: :ok | :error
def update_user_email(user, token) do
context = "change:#{user.email}"
@ -200,7 +205,7 @@ defmodule Cannery.Accounts do
end
end
@spec user_email_multi(User.t(), String.t(), String.t()) :: Multi.t()
@spec user_email_multi(User.t(), email :: String.t(), context :: String.t()) :: Multi.t()
defp user_email_multi(user, email, context) do
changeset = user |> User.email_changeset(%{email: email}) |> User.confirm_changeset()
@ -218,7 +223,8 @@ defmodule Cannery.Accounts do
{:ok, %{to: ..., body: ...}}
"""
@spec deliver_update_email_instructions(User.t(), String.t(), function) :: Job.t()
@spec deliver_update_email_instructions(User.t(), current_email :: String.t(), function) ::
Job.t()
def deliver_update_email_instructions(user, current_email, update_email_url_fun)
when is_function(update_email_url_fun, 1) do
{encoded_token, user_token} = UserToken.build_email_token(user, "change:#{current_email}")
@ -235,7 +241,7 @@ defmodule Cannery.Accounts do
%Changeset{data: %User{}}
"""
@spec change_user_password(User.t(), map()) :: Changeset.t(User.t())
@spec change_user_password(User.t(), attrs :: map()) :: User.changeset()
def change_user_password(user, attrs \\ %{}),
do: User.password_changeset(user, attrs, hash_password: false)
@ -251,8 +257,8 @@ defmodule Cannery.Accounts do
{:error, %Changeset{}}
"""
@spec update_user_password(User.t(), String.t(), map()) ::
{:ok, User.t()} | {:error, Changeset.t(User.t())}
@spec update_user_password(User.t(), String.t(), attrs :: map()) ::
{:ok, User.t()} | {:error, User.changeset()}
def update_user_password(user, password, attrs) do
changeset =
user
@ -278,7 +284,7 @@ defmodule Cannery.Accounts do
%Changeset{data: %User{}}
"""
@spec change_user_locale(User.t()) :: Changeset.t(User.t())
@spec change_user_locale(User.t()) :: User.changeset()
def change_user_locale(%{locale: locale} = user), do: User.locale_changeset(user, locale)
@doc """
@ -294,7 +300,7 @@ defmodule Cannery.Accounts do
"""
@spec update_user_locale(User.t(), locale :: String.t()) ::
{:ok, User.t()} | {:error, Changeset.t(User.t())}
{:ok, User.t()} | {:error, User.changeset()}
def update_user_locale(user, locale),
do: user |> User.locale_changeset(locale) |> Repo.update()
@ -310,7 +316,7 @@ defmodule Cannery.Accounts do
%User{}
"""
@spec delete_user!(User.t(), User.t()) :: User.t()
@spec delete_user!(user_to_delete :: User.t(), User.t()) :: User.t()
def delete_user!(user, %User{role: :admin}), do: user |> Repo.delete!()
def delete_user!(%User{id: user_id} = user, %User{id: user_id}), do: user |> Repo.delete!()
@ -329,7 +335,7 @@ defmodule Cannery.Accounts do
@doc """
Gets the user with the given signed token.
"""
@spec get_user_by_session_token(String.t()) :: User.t()
@spec get_user_by_session_token(token :: String.t()) :: User.t()
def get_user_by_session_token(token) do
{:ok, query} = UserToken.verify_session_token_query(token)
Repo.one(query)
@ -338,7 +344,7 @@ defmodule Cannery.Accounts do
@doc """
Deletes the signed token with the given context.
"""
@spec delete_session_token(String.t()) :: :ok
@spec delete_session_token(token :: String.t()) :: :ok
def delete_session_token(token) do
Repo.delete_all(UserToken.token_and_context_query(token, "session"))
:ok
@ -394,7 +400,7 @@ defmodule Cannery.Accounts do
If the token matches, the user account is marked as confirmed
and the token is deleted.
"""
@spec confirm_user(String.t()) :: {:ok, User.t()} | atom()
@spec confirm_user(token :: String.t()) :: {:ok, User.t()} | :error
def confirm_user(token) do
with {:ok, query} <- UserToken.verify_email_token_query(token, "confirm"),
%User{} = user <- Repo.one(query),
@ -443,7 +449,7 @@ defmodule Cannery.Accounts do
nil
"""
@spec get_user_by_reset_password_token(String.t()) :: User.t() | nil
@spec get_user_by_reset_password_token(token :: String.t()) :: User.t() | nil
def get_user_by_reset_password_token(token) do
with {:ok, query} <- UserToken.verify_email_token_query(token, "reset_password"),
%User{} = user <- Repo.one(query) do
@ -465,7 +471,8 @@ defmodule Cannery.Accounts do
{:error, %Changeset{}}
"""
@spec reset_user_password(User.t(), map()) :: {:ok, User.t()} | {:error, Changeset.t(User.t())}
@spec reset_user_password(User.t(), attrs :: map()) ::
{:ok, User.t()} | {:error, User.changeset()}
def reset_user_password(user, attrs) do
Multi.new()
|> Multi.update(:user, User.password_changeset(user, attrs))

View File

@ -39,7 +39,7 @@ defmodule Cannery.Accounts.User do
password: String.t(),
hashed_password: String.t(),
confirmed_at: NaiveDateTime.t(),
role: atom(),
role: role(),
locale: String.t() | nil,
invites: [Invite.t()],
inserted_at: NaiveDateTime.t(),
@ -47,6 +47,8 @@ defmodule Cannery.Accounts.User do
}
@type new_user :: %User{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_user())
@type role :: :admin | :user | String.t()
@doc """
A user changeset for registration.
@ -65,26 +67,24 @@ defmodule Cannery.Accounts.User do
validations on a LiveView form), this option can be set to `false`.
Defaults to `true`.
"""
@spec registration_changeset(t() | new_user(), attrs :: map()) :: Changeset.t(t() | new_user())
@spec registration_changeset(t() | new_user(), attrs :: map(), opts :: keyword()) ::
Changeset.t(t() | new_user())
def registration_changeset(user, attrs, opts \\ []) do
user
|> cast(attrs, [:email, :password, :role, :locale])
@spec registration_changeset(attrs :: map()) :: changeset()
@spec registration_changeset(attrs :: map(), opts :: keyword()) :: changeset()
def registration_changeset(attrs, opts \\ []) do
%User{}
|> cast(attrs, [:email, :password, :locale])
|> validate_email()
|> validate_password(opts)
end
@doc """
A user changeset for role.
"""
@spec role_changeset(t(), role :: atom()) :: Changeset.t(t())
@spec role_changeset(t() | new_user() | changeset(), role()) :: changeset()
def role_changeset(user, role) do
user |> cast(%{"role" => role}, [:role])
end
@spec validate_email(Changeset.t(t() | new_user())) :: Changeset.t(t() | new_user())
@spec validate_email(changeset()) :: changeset()
defp validate_email(changeset) do
changeset
|> validate_required([:email])
@ -96,8 +96,8 @@ defmodule Cannery.Accounts.User do
|> unique_constraint(:email)
end
@spec validate_password(Changeset.t(t() | new_user()), opts :: keyword()) ::
Changeset.t(t() | new_user())
@spec validate_password(changeset(), opts :: keyword()) ::
changeset()
defp validate_password(changeset, opts) do
changeset
|> validate_required([:password])
@ -108,8 +108,7 @@ defmodule Cannery.Accounts.User do
|> maybe_hash_password(opts)
end
@spec maybe_hash_password(Changeset.t(t() | new_user()), opts :: keyword()) ::
Changeset.t(t() | new_user())
@spec maybe_hash_password(changeset(), opts :: keyword()) :: changeset()
defp maybe_hash_password(changeset, opts) do
hash_password? = Keyword.get(opts, :hash_password, true)
password = get_change(changeset, :password)
@ -128,7 +127,7 @@ defmodule Cannery.Accounts.User do
It requires the email to change otherwise an error is added.
"""
@spec email_changeset(t(), attrs :: map()) :: Changeset.t(t())
@spec email_changeset(t(), attrs :: map()) :: changeset()
def email_changeset(user, attrs) do
user
|> cast(attrs, [:email])
@ -151,8 +150,8 @@ defmodule Cannery.Accounts.User do
validations on a LiveView form), this option can be set to `false`.
Defaults to `true`.
"""
@spec password_changeset(t(), attrs :: map()) :: Changeset.t(t())
@spec password_changeset(t(), attrs :: map(), opts :: keyword()) :: Changeset.t(t())
@spec password_changeset(t(), attrs :: map()) :: changeset()
@spec password_changeset(t(), attrs :: map(), opts :: keyword()) :: changeset()
def password_changeset(user, attrs, opts \\ []) do
user
|> cast(attrs, [:password])
@ -163,7 +162,7 @@ defmodule Cannery.Accounts.User do
@doc """
Confirms the account by setting `confirmed_at`.
"""
@spec confirm_changeset(t() | Changeset.t(t())) :: Changeset.t(t())
@spec confirm_changeset(t() | changeset()) :: changeset()
def confirm_changeset(user_or_changeset) do
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
user_or_changeset |> change(confirmed_at: now)
@ -189,7 +188,7 @@ defmodule Cannery.Accounts.User do
@doc """
Validates the current password otherwise adds an error to the changeset.
"""
@spec validate_current_password(Changeset.t(t()), String.t()) :: Changeset.t(t())
@spec validate_current_password(changeset(), String.t()) :: changeset()
def validate_current_password(changeset, password) do
if valid_password?(changeset.data, password),
do: changeset,
@ -199,7 +198,7 @@ defmodule Cannery.Accounts.User do
@doc """
A changeset for changing the user's locale
"""
@spec locale_changeset(t() | Changeset.t(t()), locale :: String.t() | nil) :: Changeset.t(t())
@spec locale_changeset(t() | changeset(), locale :: String.t() | nil) :: changeset()
def locale_changeset(user_or_changeset, locale) do
user_or_changeset
|> cast(%{"locale" => locale}, [:locale])

View File

@ -5,7 +5,7 @@ defmodule Cannery.ActivityLog do
import Ecto.Query, warn: false
alias Cannery.{Accounts.User, ActivityLog.ShotGroup, Ammo.AmmoGroup, Repo}
alias Ecto.{Changeset, Multi}
alias Ecto.Multi
@doc """
Returns the list of shot_groups.
@ -58,7 +58,7 @@ defmodule Cannery.ActivityLog do
"""
@spec create_shot_group(attrs :: map(), User.t(), AmmoGroup.t()) ::
{:ok, ShotGroup.t()} | {:error, Changeset.t(ShotGroup.t()) | nil}
{:ok, ShotGroup.t()} | {:error, ShotGroup.changeset() | nil}
def create_shot_group(attrs, user, ammo_group) do
Multi.new()
|> Multi.insert(
@ -99,7 +99,7 @@ defmodule Cannery.ActivityLog do
"""
@spec update_shot_group(ShotGroup.t(), attrs :: map(), User.t()) ::
{:ok, ShotGroup.t()} | {:error, Changeset.t(ShotGroup.t()) | nil}
{:ok, ShotGroup.t()} | {:error, ShotGroup.changeset() | nil}
def update_shot_group(
%ShotGroup{count: count, user_id: user_id} = shot_group,
attrs,
@ -149,7 +149,7 @@ defmodule Cannery.ActivityLog do
"""
@spec delete_shot_group(ShotGroup.t(), User.t()) ::
{:ok, ShotGroup.t()} | {:error, Changeset.t(ShotGroup.t())}
{:ok, ShotGroup.t()} | {:error, ShotGroup.changeset()}
def delete_shot_group(
%ShotGroup{user_id: user_id} = shot_group,
%User{id: user_id}

View File

@ -44,6 +44,7 @@ defmodule Cannery.ActivityLog.ShotGroup do
}
@type new_shot_group :: %ShotGroup{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_shot_group())
@doc false
@spec create_changeset(
@ -51,8 +52,7 @@ defmodule Cannery.ActivityLog.ShotGroup do
User.t() | any(),
AmmoGroup.t() | any(),
attrs :: map()
) ::
Changeset.t(new_shot_group())
) :: changeset()
def create_changeset(
shot_group,
%User{id: user_id},
@ -87,8 +87,7 @@ defmodule Cannery.ActivityLog.ShotGroup do
end
@doc false
@spec update_changeset(t() | new_shot_group(), User.t(), attrs :: map()) ::
Changeset.t(t() | new_shot_group())
@spec update_changeset(t() | new_shot_group(), User.t(), attrs :: map()) :: changeset()
def update_changeset(
%ShotGroup{user_id: user_id} = shot_group,
%User{id: user_id} = user,

View File

@ -182,7 +182,7 @@ defmodule Cannery.Ammo do
"""
@spec create_ammo_type(attrs :: map(), User.t()) ::
{:ok, AmmoType.t()} | {:error, Changeset.t(AmmoType.new_ammo_type())}
{:ok, AmmoType.t()} | {:error, AmmoType.changeset()}
def create_ammo_type(attrs \\ %{}, %User{} = user),
do: %AmmoType{} |> AmmoType.create_changeset(user, attrs) |> Repo.insert()
@ -199,7 +199,7 @@ defmodule Cannery.Ammo do
"""
@spec update_ammo_type(AmmoType.t(), attrs :: map(), User.t()) ::
{:ok, AmmoType.t()} | {:error, Changeset.t(AmmoType.t())}
{:ok, AmmoType.t()} | {:error, AmmoType.changeset()}
def update_ammo_type(%AmmoType{user_id: user_id} = ammo_type, attrs, %User{id: user_id}),
do: ammo_type |> AmmoType.update_changeset(attrs) |> Repo.update()
@ -216,7 +216,7 @@ defmodule Cannery.Ammo do
"""
@spec delete_ammo_type(AmmoType.t(), User.t()) ::
{:ok, AmmoType.t()} | {:error, Changeset.t(AmmoType.t())}
{:ok, AmmoType.t()} | {:error, AmmoType.changeset()}
def delete_ammo_type(%AmmoType{user_id: user_id} = ammo_type, %User{id: user_id}),
do: ammo_type |> Repo.delete()
@ -549,7 +549,7 @@ defmodule Cannery.Ammo do
"""
@spec create_ammo_groups(attrs :: map(), multiplier :: non_neg_integer(), User.t()) ::
{:ok, {count :: non_neg_integer(), [AmmoGroup.t()] | nil}}
| {:error, Changeset.t(AmmoGroup.new_ammo_group())}
| {:error, AmmoGroup.changeset()}
def create_ammo_groups(
%{"ammo_type_id" => ammo_type_id, "container_id" => container_id} = attrs,
multiplier,
@ -628,7 +628,7 @@ defmodule Cannery.Ammo do
"""
@spec update_ammo_group(AmmoGroup.t(), attrs :: map(), User.t()) ::
{:ok, AmmoGroup.t()} | {:error, Changeset.t(AmmoGroup.t())}
{:ok, AmmoGroup.t()} | {:error, AmmoGroup.changeset()}
def update_ammo_group(
%AmmoGroup{user_id: user_id} = ammo_group,
attrs,
@ -649,7 +649,7 @@ defmodule Cannery.Ammo do
"""
@spec delete_ammo_group(AmmoGroup.t(), User.t()) ::
{:ok, AmmoGroup.t()} | {:error, Changeset.t(AmmoGroup.t())}
{:ok, AmmoGroup.t()} | {:error, AmmoGroup.changeset()}
def delete_ammo_group(%AmmoGroup{user_id: user_id} = ammo_group, %User{id: user_id}),
do: ammo_group |> Repo.delete()

View File

@ -59,6 +59,7 @@ defmodule Cannery.Ammo.AmmoGroup do
}
@type new_ammo_group :: %AmmoGroup{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_ammo_group())
@doc false
@spec create_changeset(
@ -67,7 +68,7 @@ defmodule Cannery.Ammo.AmmoGroup do
Container.t() | nil,
User.t(),
attrs :: map()
) :: Changeset.t(new_ammo_group())
) :: changeset()
def create_changeset(
ammo_group,
%AmmoType{id: ammo_type_id},
@ -97,8 +98,7 @@ defmodule Cannery.Ammo.AmmoGroup do
end
@doc false
@spec update_changeset(t() | new_ammo_group(), attrs :: map(), User.t()) ::
Changeset.t(t() | new_ammo_group())
@spec update_changeset(t() | new_ammo_group(), attrs :: map(), User.t()) :: changeset()
def update_changeset(ammo_group, attrs, user) do
ammo_group
|> cast(attrs, [:count, :price_paid, :notes, :staged, :purchased_on, :container_id])
@ -121,8 +121,7 @@ defmodule Cannery.Ammo.AmmoGroup do
This range changeset is used when "using up" ammo groups, and allows for
updating the count to 0
"""
@spec range_changeset(t() | new_ammo_group(), attrs :: map()) ::
Changeset.t(t() | new_ammo_group())
@spec range_changeset(t() | new_ammo_group(), attrs :: map()) :: changeset()
def range_changeset(ammo_group, attrs) do
ammo_group
|> cast(attrs, [:count, :staged])

View File

@ -102,6 +102,7 @@ defmodule Cannery.Ammo.AmmoType do
}
@type new_ammo_type :: %AmmoType{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_ammo_type())
@spec changeset_fields() :: [atom()]
defp changeset_fields,
@ -130,8 +131,7 @@ defmodule Cannery.Ammo.AmmoType do
]
@doc false
@spec create_changeset(new_ammo_type(), User.t(), attrs :: map()) ::
Changeset.t(new_ammo_type())
@spec create_changeset(new_ammo_type(), User.t(), attrs :: map()) :: changeset()
def create_changeset(ammo_type, %User{id: user_id}, attrs) do
ammo_type
|> change(user_id: user_id)
@ -140,8 +140,7 @@ defmodule Cannery.Ammo.AmmoType do
end
@doc false
@spec update_changeset(t() | new_ammo_type(), attrs :: map()) ::
Changeset.t(t() | new_ammo_type())
@spec update_changeset(t() | new_ammo_type(), attrs :: map()) :: changeset()
def update_changeset(ammo_type, attrs) do
ammo_type
|> cast(attrs, changeset_fields())

View File

@ -89,7 +89,7 @@ defmodule Cannery.Containers do
"""
@spec create_container(attrs :: map(), User.t()) ::
{:ok, Container.t()} | {:error, Changeset.t(Container.new_container())}
{:ok, Container.t()} | {:error, Container.changeset()}
def create_container(attrs, %User{} = user) do
%Container{} |> Container.create_changeset(user, attrs) |> Repo.insert()
end
@ -107,7 +107,7 @@ defmodule Cannery.Containers do
"""
@spec update_container(Container.t(), User.t(), attrs :: map()) ::
{:ok, Container.t()} | {:error, Changeset.t(Container.t())}
{:ok, Container.t()} | {:error, Container.changeset()}
def update_container(%Container{user_id: user_id} = container, %User{id: user_id}, attrs) do
container |> Container.update_changeset(attrs) |> Repo.update()
end
@ -125,7 +125,7 @@ defmodule Cannery.Containers do
"""
@spec delete_container(Container.t(), User.t()) ::
{:ok, Container.t()} | {:error, Changeset.t(Container.t())}
{:ok, Container.t()} | {:error, Container.changeset()}
def delete_container(%Container{user_id: user_id} = container, %User{id: user_id}) do
Repo.one(
from ag in AmmoGroup,

View File

@ -49,10 +49,10 @@ defmodule Cannery.Containers.Container do
}
@type new_container :: %Container{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_container())
@doc false
@spec create_changeset(new_container(), User.t(), attrs :: map()) ::
Changeset.t(new_container())
@spec create_changeset(new_container(), User.t(), attrs :: map()) :: changeset()
def create_changeset(container, %User{id: user_id}, attrs) do
container
|> change(user_id: user_id)
@ -61,8 +61,7 @@ defmodule Cannery.Containers.Container do
end
@doc false
@spec update_changeset(t() | new_container(), attrs :: map()) ::
Changeset.t(t() | new_container())
@spec update_changeset(t() | new_container(), attrs :: map()) :: changeset()
def update_changeset(container, attrs) do
container
|> cast(attrs, [:name, :desc, :type, :location])

View File

@ -29,10 +29,10 @@ defmodule Cannery.Containers.ContainerTag do
}
@type new_container_tag :: %ContainerTag{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_container_tag())
@doc false
@spec create_changeset(new_container_tag(), Tag.t(), Container.t()) ::
Changeset.t(new_container_tag())
@spec create_changeset(new_container_tag(), Tag.t(), Container.t()) :: changeset()
def create_changeset(
container_tag,
%Tag{id: tag_id, user_id: user_id},

View File

@ -5,7 +5,6 @@ defmodule Cannery.Invites do
import Ecto.Query, warn: false
alias Cannery.{Accounts.User, Invites.Invite, Repo}
alias Ecto.Changeset
@invite_token_length 20
@ -99,14 +98,14 @@ defmodule Cannery.Invites do
"""
@spec create_invite(User.t(), attrs :: map()) ::
{:ok, Invite.t()} | {:error, Changeset.t(Invite.new_invite())}
{:ok, Invite.t()} | {:error, Invite.changeset()}
def create_invite(%User{role: :admin} = user, attrs) do
token =
:crypto.strong_rand_bytes(@invite_token_length)
|> Base.url_encode64()
|> binary_part(0, @invite_token_length)
%Invite{} |> Invite.create_changeset(user, token, attrs) |> Repo.insert()
Invite.create_changeset(user, token, attrs) |> Repo.insert()
end
@doc """
@ -122,7 +121,7 @@ defmodule Cannery.Invites do
"""
@spec update_invite(Invite.t(), attrs :: map(), User.t()) ::
{:ok, Invite.t()} | {:error, Changeset.t(Invite.t())}
{:ok, Invite.t()} | {:error, Invite.changeset()}
def update_invite(invite, attrs, %User{role: :admin}),
do: invite |> Invite.update_changeset(attrs) |> Repo.update()
@ -139,7 +138,7 @@ defmodule Cannery.Invites do
"""
@spec delete_invite(Invite.t(), User.t()) ::
{:ok, Invite.t()} | {:error, Changeset.t(Invite.t())}
{:ok, Invite.t()} | {:error, Invite.changeset()}
def delete_invite(invite, %User{role: :admin}), do: invite |> Repo.delete()
@doc """

View File

@ -36,12 +36,12 @@ defmodule Cannery.Invites.Invite do
}
@type new_invite :: %Invite{}
@type id :: UUID.t()
@type changeset :: Changeset.t(t() | new_invite())
@doc false
@spec create_changeset(new_invite(), User.t(), token :: binary(), attrs :: map()) ::
Changeset.t(new_invite())
def create_changeset(invite, %User{id: user_id}, token, attrs) do
invite
@spec create_changeset(User.t(), token :: binary(), attrs :: map()) :: changeset()
def create_changeset(%User{id: user_id}, token, attrs) do
%Invite{}
|> change(token: token, user_id: user_id)
|> cast(attrs, [:name, :uses_left, :disabled_at])
|> validate_required([:name, :token, :user_id])
@ -49,7 +49,7 @@ defmodule Cannery.Invites.Invite do
end
@doc false
@spec update_changeset(t() | new_invite(), attrs :: map()) :: Changeset.t(t() | new_invite())
@spec update_changeset(t() | new_invite(), attrs :: map()) :: changeset()
def update_changeset(invite, attrs) do
invite
|> cast(attrs, [:name, :uses_left, :disabled_at])

View File

@ -6,7 +6,6 @@ defmodule Cannery.Tags do
import Ecto.Query, warn: false
import CanneryWeb.Gettext
alias Cannery.{Accounts.User, Repo, Tags.Tag}
alias Ecto.Changeset
@doc """
Returns the list of tags.
@ -73,7 +72,7 @@ defmodule Cannery.Tags do
"""
@spec create_tag(attrs :: map(), User.t()) ::
{:ok, Tag.t()} | {:error, Changeset.t(Tag.new_tag())}
{:ok, Tag.t()} | {:error, Tag.changeset()}
def create_tag(attrs, %User{} = user),
do: %Tag{} |> Tag.create_changeset(user, attrs) |> Repo.insert()
@ -90,7 +89,7 @@ defmodule Cannery.Tags do
"""
@spec update_tag(Tag.t(), attrs :: map(), User.t()) ::
{:ok, Tag.t()} | {:error, Changeset.t(Tag.t())}
{:ok, Tag.t()} | {:error, Tag.changeset()}
def update_tag(%Tag{user_id: user_id} = tag, attrs, %User{id: user_id}),
do: tag |> Tag.update_changeset(attrs) |> Repo.update()
@ -106,7 +105,7 @@ defmodule Cannery.Tags do
{:error, %Changeset{}}
"""
@spec delete_tag(Tag.t(), User.t()) :: {:ok, Tag.t()} | {:error, Changeset.t(Tag.t())}
@spec delete_tag(Tag.t(), User.t()) :: {:ok, Tag.t()} | {:error, Tag.changeset()}
def delete_tag(%Tag{user_id: user_id} = tag, %User{id: user_id}), do: tag |> Repo.delete()
@doc """

View File

@ -40,9 +40,10 @@ defmodule Cannery.Tags.Tag do
}
@type new_tag() :: %Tag{}
@type id() :: UUID.t()
@type changeset() :: Changeset.t(t() | new_tag())
@doc false
@spec create_changeset(new_tag(), User.t(), attrs :: map()) :: Changeset.t(new_tag())
@spec create_changeset(new_tag(), User.t(), attrs :: map()) :: changeset()
def create_changeset(tag, %User{id: user_id}, attrs) do
tag
|> change(user_id: user_id)
@ -51,7 +52,7 @@ defmodule Cannery.Tags.Tag do
end
@doc false
@spec update_changeset(t() | new_tag(), attrs :: map()) :: Changeset.t(t() | new_tag())
@spec update_changeset(t() | new_tag(), attrs :: map()) :: changeset()
def update_changeset(tag, attrs) do
tag
|> cast(attrs, [:name, :bg_color, :text_color])

View File

@ -2,7 +2,6 @@ defmodule CanneryWeb.UserRegistrationController do
use CanneryWeb, :controller
import CanneryWeb.Gettext
alias Cannery.{Accounts, Invites}
alias Cannery.Accounts.User
alias CanneryWeb.{Endpoint, HomeLive}
def new(conn, %{"invite" => invite_token}) do
@ -30,7 +29,7 @@ defmodule CanneryWeb.UserRegistrationController do
# renders new user registration page
defp render_new(conn, invite \\ nil) do
render(conn, "new.html",
changeset: Accounts.change_user_registration(%User{}),
changeset: Accounts.change_user_registration(),
invite: invite,
page_title: gettext("Register")
)

View File

@ -38,7 +38,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
changeset =
case action do
:new -> invite |> Invite.create_changeset(user, "example_token", invite_params)
:new -> Invite.create_changeset(user, "example_token", invite_params)
:edit -> invite |> Invite.update_changeset(invite_params)
end

View File

@ -4,7 +4,7 @@ defmodule Cannery.MixProject do
def project do
[
app: :cannery,
version: "0.7.1",
version: "0.7.2",
elixir: "1.14.1",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: Mix.compilers(),

View File

@ -711,7 +711,7 @@ msgstr "Passwort vergessen?"
msgid "Log in"
msgstr "Einloggen"
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr "Registrieren"

View File

@ -83,14 +83,14 @@ msgstr "Oops, etwas ist schiefgegangen. Bitte beachten Sie den Fehler unten."
msgid "Reset password link is invalid or it has expired."
msgstr "Link zum Passwort zurücksetzen ist ungültig oder abgelaufen."
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr "Entschuldigung, aber öffentliche Registrierung ist deaktiviert"
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr ""
@ -121,17 +121,17 @@ msgstr "Sie sind nicht berechtigt, diese Seite aufzurufen"
msgid "You are not authorized to view this page."
msgstr "Sie sind nicht berechtigt, diese Seite aufzurufen."
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr "hat sich nicht geändert"
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr "Passwort stimmt nicht überein"
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format
msgid "is not valid"
msgstr "ist nicht gültig"
@ -141,7 +141,7 @@ msgstr "ist nicht gültig"
msgid "must have the @ sign and no spaces"
msgstr "Muss ein @ Zeichen und keine Leerzeichen haben"
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr "Tag nicht gefunden"
@ -151,13 +151,13 @@ msgstr "Tag nicht gefunden"
msgid "Tag could not be added"
msgstr "Tag konnte nicht hinzugefügt werden"
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr "Anzahl muss mindestens 1 sein"
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr "Anzahl muss weniger als %{count} betragen"
@ -192,7 +192,7 @@ msgstr ""
msgid "Invalid multiplier"
msgstr ""
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr ""

View File

@ -150,7 +150,7 @@ msgstr "Passwort erfolgreich zurückgesetzt."
msgid "Password updated successfully."
msgstr "Passwort erfolgreich geändert."
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr "Bitte überprüfen Sie ihre Mailbox und bestätigen Sie das Nutzerkonto"

View File

@ -694,7 +694,7 @@ msgstr ""
msgid "Log in"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""

View File

@ -695,7 +695,7 @@ msgstr ""
msgid "Log in"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""

View File

@ -70,14 +70,14 @@ msgstr ""
msgid "Reset password link is invalid or it has expired."
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr ""
@ -107,18 +107,18 @@ msgstr ""
msgid "You are not authorized to view this page."
msgstr ""
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr ""
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr ""
## From Ecto.Changeset.put_change/3
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format, fuzzy
msgid "is not valid"
msgstr ""
@ -128,7 +128,7 @@ msgstr ""
msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr ""
@ -138,13 +138,13 @@ msgstr ""
msgid "Tag could not be added"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr ""
@ -175,7 +175,7 @@ msgstr ""
msgid "Invalid multiplier"
msgstr ""
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr ""

View File

@ -132,7 +132,7 @@ msgstr ""
msgid "Password updated successfully."
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr ""

View File

@ -70,14 +70,14 @@ msgstr ""
msgid "Reset password link is invalid or it has expired."
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr ""
@ -107,17 +107,17 @@ msgstr ""
msgid "You are not authorized to view this page."
msgstr ""
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr ""
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr ""
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format
msgid "is not valid"
msgstr ""
@ -127,7 +127,7 @@ msgstr ""
msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr ""
@ -137,13 +137,13 @@ msgstr ""
msgid "Tag could not be added"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr ""
@ -174,7 +174,7 @@ msgstr ""
msgid "Invalid multiplier"
msgstr ""
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr ""

View File

@ -709,7 +709,7 @@ msgstr ""
msgid "Log in"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""

View File

@ -86,14 +86,14 @@ msgid "Reset password link is invalid or it has expired."
msgstr ""
"El enlace de reestablecimiento de la contraseña es inválido o ha caducado."
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr "Lo sentimos, la inscripción pública está desactivada"
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr "Lo sentimos, esta invitación no fue encontrada o ha expirado"
@ -123,17 +123,17 @@ msgstr "No está autorizado a ver esta página"
msgid "You are not authorized to view this page."
msgstr "No está autorizado a ver esta página."
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr "no cambió"
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr "no coincide con la contraseña"
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format
msgid "is not valid"
msgstr "no es válido"
@ -143,7 +143,7 @@ msgstr "no es válido"
msgid "must have the @ sign and no spaces"
msgstr "debe tener el signo @ y no contener espacios"
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr "Etiqueta no encontrada"
@ -153,13 +153,13 @@ msgstr "Etiqueta no encontrada"
msgid "Tag could not be added"
msgstr "La etiqueta no pudo ser añadida"
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr "El recuento debe dar al menos 1"
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr "El recuento debe ser menos de %{count}"
@ -190,7 +190,7 @@ msgstr "Número inválido de copias, debe ser entre 1 y %{max}. Fue %{multiplier
msgid "Invalid multiplier"
msgstr "Multiplicador inválido"
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr ""

View File

@ -150,7 +150,7 @@ msgstr "Contraseña reiniciada exitosamente."
msgid "Password updated successfully."
msgstr "Contraseña cambiada exitosamente."
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr "Por favor chequea el correo para verificar tu cuenta"

View File

@ -713,7 +713,7 @@ msgstr "Mot de passe oublié?"
msgid "Log in"
msgstr "Se connecter"
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr "Senregistrer"

View File

@ -85,14 +85,14 @@ msgstr ""
msgid "Reset password link is invalid or it has expired."
msgstr "Le lien de réinitialisation de mot de passe est invalide ou expiré."
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr "Désolé, lenregistrement public est désactivé"
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr "Désolé, cette invitation nest pas trouvée ou est expirée"
@ -122,17 +122,17 @@ msgstr "Vous nêtes pas autorisé·e à voir cette page"
msgid "You are not authorized to view this page."
msgstr "Vous nêtes pas autorisé·e à voir cette page."
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr "est inchangé"
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr "le mot de passe ne correspond pas"
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format
msgid "is not valid"
msgstr "nest pas valide"
@ -142,7 +142,7 @@ msgstr "nest pas valide"
msgid "must have the @ sign and no spaces"
msgstr "doit contenir le symbole @ et aucune espace"
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr "Tag pas trouvé"
@ -152,13 +152,13 @@ msgstr "Tag pas trouvé"
msgid "Tag could not be added"
msgstr "Le tag na pas pu être ajouté"
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr "Le nombre doit être au moins égal à 1"
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr "La quantité doit être inférieur à %{count}"
@ -191,7 +191,7 @@ msgstr "Nombre de copies invalide, doit être 1 et %{max}. Été %{multiplier}"
msgid "Invalid multiplier"
msgstr "Multiplicateur invalide"
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr "Veuillez choisir un type de munitions et un conteneur"

View File

@ -151,7 +151,7 @@ msgstr "Mot de passe réinitialiser avec succès."
msgid "Password updated successfully."
msgstr "Mot de passe mis à jour avec succès."
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr "Veuillez vérifier votre mél pour confirmer votre compte"

View File

@ -705,7 +705,7 @@ msgstr ""
msgid "Log in"
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:35
#: lib/cannery_web/controllers/user_registration_controller.ex:34
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""

View File

@ -86,14 +86,14 @@ msgstr ""
msgid "Reset password link is invalid or it has expired."
msgstr "Tá nasc an pasfhocail a athrú neamhbailí nó as dáta."
#: lib/cannery_web/controllers/user_registration_controller.ex:25
#: lib/cannery_web/controllers/user_registration_controller.ex:56
#: lib/cannery_web/controllers/user_registration_controller.ex:24
#: lib/cannery_web/controllers/user_registration_controller.ex:55
#, elixir-autogen, elixir-format
msgid "Sorry, public registration is disabled"
msgstr "Tá brón orainn, tá clarú póiblí bactha"
#: lib/cannery_web/controllers/user_registration_controller.ex:15
#: lib/cannery_web/controllers/user_registration_controller.ex:46
#: lib/cannery_web/controllers/user_registration_controller.ex:14
#: lib/cannery_web/controllers/user_registration_controller.ex:45
#, elixir-autogen, elixir-format
msgid "Sorry, this invite was not found or expired"
msgstr "Tá brón orainn, ní feidir an cuireadh seo a fáil nó tá sé as dáta"
@ -123,17 +123,17 @@ msgstr "Níl cead agaibh féachaint ar an leathanach seo"
msgid "You are not authorized to view this page."
msgstr "Níl cead agaibh féachaint ar an leathanach seo."
#: lib/cannery/accounts/user.ex:138
#: lib/cannery/accounts/user.ex:137
#, elixir-autogen, elixir-format
msgid "did not change"
msgstr "Níor athraigh sé"
#: lib/cannery/accounts/user.ex:159
#: lib/cannery/accounts/user.ex:158
#, elixir-autogen, elixir-format
msgid "does not match password"
msgstr ""
#: lib/cannery/accounts/user.ex:196
#: lib/cannery/accounts/user.ex:195
#, elixir-autogen, elixir-format
msgid "is not valid"
msgstr ""
@ -143,7 +143,7 @@ msgstr ""
msgid "must have the @ sign and no spaces"
msgstr ""
#: lib/cannery/tags.ex:40
#: lib/cannery/tags.ex:39
#, elixir-autogen, elixir-format
msgid "Tag not found"
msgstr ""
@ -153,13 +153,13 @@ msgstr ""
msgid "Tag could not be added"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:123
#: lib/cannery/activity_log/shot_group.ex:122
#, elixir-autogen, elixir-format
msgid "Count must be at least 1"
msgstr ""
#: lib/cannery/activity_log/shot_group.ex:82
#: lib/cannery/activity_log/shot_group.ex:119
#: lib/cannery/activity_log/shot_group.ex:118
#, elixir-autogen, elixir-format
msgid "Count must be less than %{count}"
msgstr ""
@ -190,7 +190,7 @@ msgstr ""
msgid "Invalid multiplier"
msgstr ""
#: lib/cannery/ammo/ammo_group.ex:96
#: lib/cannery/ammo/ammo_group.ex:97
#, elixir-autogen, elixir-format
msgid "Please select an ammo type and container"
msgstr ""

View File

@ -142,7 +142,7 @@ msgstr ""
msgid "Password updated successfully."
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr ""

View File

@ -131,7 +131,7 @@ msgstr ""
msgid "Password updated successfully."
msgstr ""
#: lib/cannery_web/controllers/user_registration_controller.ex:74
#: lib/cannery_web/controllers/user_registration_controller.ex:73
#, elixir-autogen, elixir-format
msgid "Please check your email to verify your account"
msgstr ""

View File

@ -104,7 +104,7 @@ defmodule Cannery.AccountsTest do
describe "change_user_registration/2" do
test "returns a changeset" do
assert %Changeset{} = changeset = Accounts.change_user_registration(%User{})
assert %Changeset{} = changeset = Accounts.change_user_registration()
assert changeset.required == [:password, :email]
end
@ -112,8 +112,7 @@ defmodule Cannery.AccountsTest do
email = unique_user_email()
password = valid_user_password()
changeset =
Accounts.change_user_registration(%User{}, %{"email" => email, "password" => password})
changeset = Accounts.change_user_registration(%{"email" => email, "password" => password})
assert changeset.valid?
assert get_change(changeset, :email) == email