harden invites context

This commit is contained in:
shibao 2022-02-11 00:34:29 -05:00
parent fc75948f4c
commit 71397d6b29
9 changed files with 227 additions and 185 deletions

View File

@ -4,8 +4,8 @@ defmodule Cannery.Invites do
""" """
import Ecto.Query, warn: false import Ecto.Query, warn: false
alias Ecto.Changeset
alias Cannery.{Accounts.User, Invites.Invite, Repo} alias Cannery.{Accounts.User, Invites.Invite, Repo}
alias Ecto.Changeset
@invite_token_length 20 @invite_token_length 20
@ -14,12 +14,14 @@ defmodule Cannery.Invites do
## Examples ## Examples
iex> list_invites() iex> list_invites(%User{id: 123, role: :admin})
[%Invite{}, ...] [%Invite{}, ...]
""" """
@spec list_invites() :: [Invite.t()] @spec list_invites(User.t()) :: [Invite.t()]
def list_invites, do: Repo.all(Invite) def list_invites(%User{role: :admin}) do
Repo.all(Invite)
end
@doc """ @doc """
Gets a single invite. Gets a single invite.
@ -28,15 +30,17 @@ defmodule Cannery.Invites do
## Examples ## Examples
iex> get_invite!(123) iex> get_invite!(123, %User{id: 123, role: :admin})
%Invite{} %Invite{}
iex> get_invite!(456) iex> get_invite!(456, %User{id: 123, role: :admin})
** (Ecto.NoResultsError) ** (Ecto.NoResultsError)
""" """
@spec get_invite!(Invite.id()) :: Invite.t() @spec get_invite!(Invite.id(), User.t()) :: Invite.t()
def get_invite!(id), do: Repo.get!(Invite, id) def get_invite!(id, %User{role: :admin}) do
Repo.get!(Invite, id)
end
@doc """ @doc """
Returns a valid invite or nil based on the attempted token Returns a valid invite or nil based on the attempted token
@ -55,8 +59,9 @@ defmodule Cannery.Invites do
def get_invite_by_token(token) do def get_invite_by_token(token) do
Repo.one( Repo.one(
from i in Invite, from(i in Invite,
where: i.token == ^token and i.disabled_at |> is_nil() where: i.token == ^token and i.disabled_at |> is_nil()
)
) )
end end
@ -86,21 +91,16 @@ defmodule Cannery.Invites do
## Examples ## Examples
iex> create_invite(%User{id: "1"}, %{field: value}) iex> create_invite(%User{id: 123, role: :admin}, %{field: value})
{:ok, %Invite{}} {:ok, %Invite{}}
iex> create_invite("1", %{field: value}) iex> create_invite(%User{id: 123, role: :admin}, %{field: bad_value})
{:ok, %Invite{}}
iex> create_invite(%User{id: "1"}, %{field: bad_value})
{:error, %Changeset{}} {:error, %Changeset{}}
""" """
@spec create_invite(User.t() | User.id(), attrs :: map()) :: @spec create_invite(User.t(), attrs :: map()) ::
{:ok, Invite.t()} | {:error, Changeset.t(Invite.new_invite())} {:ok, Invite.t()} | {:error, Changeset.t(Invite.new_invite())}
def create_invite(%{id: user_id}, attrs), do: create_invite(user_id, attrs) def create_invite(%User{id: user_id, role: :admin}, attrs) do
def create_invite(user_id, attrs) when not (user_id |> is_nil()) do
token = token =
:crypto.strong_rand_bytes(@invite_token_length) :crypto.strong_rand_bytes(@invite_token_length)
|> Base.url_encode64() |> Base.url_encode64()
@ -116,43 +116,45 @@ defmodule Cannery.Invites do
## Examples ## Examples
iex> update_invite(invite, %{field: new_value}) iex> update_invite(invite, %{field: new_value}, %User{id: 123, role: :admin})
{:ok, %Invite{}} {:ok, %Invite{}}
iex> update_invite(invite, %{field: bad_value}) iex> update_invite(invite, %{field: bad_value}, %User{id: 123, role: :admin})
{:error, %Changeset{}} {:error, %Changeset{}}
""" """
@spec update_invite(Invite.t(), attrs :: map()) :: @spec update_invite(Invite.t(), attrs :: map(), User.t()) ::
{:ok, Invite.t()} | {:error, Changeset.t(Invite.t())} {:ok, Invite.t()} | {:error, Changeset.t(Invite.t())}
def update_invite(invite, attrs), do: invite |> Invite.changeset(attrs) |> Repo.update() def update_invite(invite, attrs, %User{role: :admin}),
do: invite |> Invite.changeset(attrs) |> Repo.update()
@doc """ @doc """
Deletes a invite. Deletes a invite.
## Examples ## Examples
iex> delete_invite(invite) iex> delete_invite(invite, %User{id: 123, role: :admin})
{:ok, %Invite{}} {:ok, %Invite{}}
iex> delete_invite(invite) iex> delete_invite(invite, %User{id: 123, role: :admin})
{:error, %Changeset{}} {:error, %Changeset{}}
""" """
@spec delete_invite(Invite.t()) :: {:ok, Invite.t()} | {:error, Changeset.t(Invite.t())} @spec delete_invite(Invite.t(), User.t()) ::
def delete_invite(invite), do: invite |> Repo.delete() {:ok, Invite.t()} | {:error, Changeset.t(Invite.t())}
def delete_invite(invite, %User{role: :admin}), do: invite |> Repo.delete()
@doc """ @doc """
Deletes a invite. Deletes a invite.
## Examples ## Examples
iex> delete_invite(invite) iex> delete_invite(invite, %User{id: 123, role: :admin})
%Invite{} %Invite{}
""" """
@spec delete_invite!(Invite.t()) :: Invite.t() @spec delete_invite!(Invite.t(), User.t()) :: Invite.t()
def delete_invite!(invite), do: invite |> Repo.delete!() def delete_invite!(invite, %User{role: :admin}), do: invite |> Repo.delete!()
@doc """ @doc """
Returns an `%Changeset{}` for tracking invite changes. Returns an `%Changeset{}` for tracking invite changes.

View File

@ -4,8 +4,8 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
""" """
use CanneryWeb, :live_component use CanneryWeb, :live_component
alias Cannery.{Ammo, Accounts.User, Containers, Containers.Container} alias Cannery.Ammo.{AmmoGroup, AmmoType}
alias Cannery.Ammo.{AmmoType, AmmoGroup} alias Cannery.{Accounts.User, Ammo, Containers, Containers.Container}
alias Ecto.Changeset alias Ecto.Changeset
alias Phoenix.LiveView.Socket alias Phoenix.LiveView.Socket

View File

@ -14,22 +14,20 @@ defmodule CanneryWeb.InviteLive.FormComponent do
Socket.t() Socket.t()
) :: {:ok, Socket.t()} ) :: {:ok, Socket.t()}
def update(%{invite: invite} = assigns, socket) do def update(%{invite: invite} = assigns, socket) do
changeset = Invites.change_invite(invite) {:ok, socket |> assign(assigns) |> assign(:changeset, Invites.change_invite(invite))}
{:ok,
socket
|> assign(assigns)
|> assign(:changeset, changeset)}
end end
@impl true @impl true
def handle_event("validate", %{"invite" => invite_params}, socket) do def handle_event(
changeset = socket.assigns.invite |> Invites.change_invite(invite_params) "validate",
{:noreply, assign(socket, :changeset, changeset)} %{"invite" => invite_params},
%{assigns: %{invite: invite}} = socket
) do
{:noreply, socket |> assign(:changeset, invite |> Invites.change_invite(invite_params))}
end end
def handle_event("save", %{"invite" => invite_params}, socket) do def handle_event("save", %{"invite" => invite_params}, %{assigns: %{action: action}} = socket) do
save_invite(socket, socket.assigns.action, invite_params) save_invite(socket, action, invite_params)
end end
@impl true @impl true
@ -71,29 +69,39 @@ defmodule CanneryWeb.InviteLive.FormComponent do
""" """
end end
defp save_invite(socket, :edit, invite_params) do defp save_invite(
case Invites.update_invite(socket.assigns.invite, invite_params) do %{assigns: %{current_user: current_user, invite: invite, return_to: return_to}} = socket,
{:ok, _invite} -> :edit,
{:noreply, invite_params
socket ) do
|> put_flash(:info, dgettext("prompts", "Invite updated successfully")) socket =
|> push_redirect(to: socket.assigns.return_to)} case invite |> Invites.update_invite(invite_params, current_user) do
{:ok, %{name: invite_name}} ->
prompt = dgettext("prompts", "%{name} updated successfully", name: invite_name)
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
{:error, %Changeset{} = changeset} -> {:error, %Changeset{} = changeset} ->
{:noreply, assign(socket, :changeset, changeset)} socket |> assign(:changeset, changeset)
end end
{:noreply, socket}
end end
defp save_invite(socket, :new, invite_params) do defp save_invite(
case Invites.create_invite(socket.assigns.current_user, invite_params) do %{assigns: %{current_user: current_user, return_to: return_to}} = socket,
{:ok, _invite} -> :new,
{:noreply, invite_params
socket ) do
|> put_flash(:info, dgettext("prompts", "Invite created successfully")) socket =
|> push_redirect(to: socket.assigns.return_to)} case current_user |> Invites.create_invite(invite_params) do
{:ok, %{name: invite_name}} ->
prompt = dgettext("prompts", "%{name} created successfully", name: invite_name)
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
{:error, %Changeset{} = changeset} -> {:error, %Changeset{} = changeset} ->
{:noreply, assign(socket, changeset: changeset)} socket |> assign(changeset: changeset)
end end
{:noreply, socket}
end end
end end

View File

@ -14,53 +14,87 @@ defmodule CanneryWeb.InviteLive.Index do
end end
@impl true @impl true
def handle_params(params, _url, socket) do def handle_params(params, _url, %{assigns: %{live_action: live_action}} = socket) do
{:noreply, socket |> apply_action(socket.assigns.live_action, params)} {:noreply, socket |> apply_action(live_action, params)}
end end
defp apply_action(socket, :edit, %{"id" => id}) do defp apply_action(%{assigns: %{current_user: current_user}} = socket, :edit, %{"id" => id}) do
socket socket
|> assign(page_title: gettext("Edit Invite"), invite: Invites.get_invite!(id)) |> assign(page_title: gettext("Edit Invite"), invite: Invites.get_invite!(id, current_user))
end end
defp apply_action(socket, :new, _params) do defp apply_action(socket, :new, _params) do
socket socket |> assign(page_title: gettext("New Invite"), invite: %Invite{})
|> assign(page_title: gettext("New Invite"), invite: %Invite{})
end end
defp apply_action(socket, :index, _params) do defp apply_action(socket, :index, _params) do
socket socket |> assign(page_title: gettext("Listing Invites"), invite: nil)
|> assign(page_title: gettext("Listing Invites"), invite: nil)
end end
@impl true @impl true
def handle_event("delete", %{"id" => id}, socket) do def handle_event("delete", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do
invite = Invites.get_invite!(id) %{name: invite_name} =
{:ok, _} = Invites.delete_invite(invite) id |> Invites.get_invite!(current_user) |> Invites.delete_invite!(current_user)
{:noreply, socket |> display_invites()}
prompt = dgettext("prompts", "%{name} deleted succesfully", name: invite_name)
{:noreply, socket |> put_flash(:info, prompt) |> display_invites()}
end end
def handle_event("set_unlimited", %{"id" => id}, socket) do def handle_event(
id |> Invites.get_invite!() |> Invites.update_invite(%{"uses_left" => nil}) "set_unlimited",
{:noreply, socket |> display_invites()} %{"id" => id},
%{assigns: %{current_user: current_user}} = socket
) do
socket =
Invites.get_invite!(id, current_user)
|> Invites.update_invite(%{"uses_left" => nil}, current_user)
|> case do
{:ok, %{name: invite_name}} ->
prompt = dgettext("prompts", "%{name} updated succesfully", name: invite_name)
socket |> put_flash(:info, prompt) |> display_invites()
{:error, changeset} ->
socket |> put_flash(:error, changeset |> changeset_errors())
end
{:noreply, socket}
end end
def handle_event("enable", %{"id" => id}, socket) do def handle_event("enable", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do
attrs = %{"uses_left" => nil, "disabled_at" => nil} socket =
id |> Invites.get_invite!() |> Invites.update_invite(attrs) Invites.get_invite!(id, current_user)
{:noreply, socket |> display_invites()} |> Invites.update_invite(%{"uses_left" => nil, "disabled_at" => nil}, current_user)
|> case do
{:ok, %{name: invite_name}} ->
prompt = dgettext("prompts", "%{name} enabled succesfully", name: invite_name)
socket |> put_flash(:info, prompt) |> display_invites()
{:error, changeset} ->
socket |> put_flash(:error, changeset |> changeset_errors())
end
{:noreply, socket}
end end
def handle_event("disable", %{"id" => id}, socket) do def handle_event("disable", %{"id" => id}, %{assigns: %{current_user: current_user}} = socket) do
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
attrs = %{"uses_left" => 0, "disabled_at" => now}
id |> Invites.get_invite!() |> Invites.update_invite(attrs) socket =
{:noreply, socket |> display_invites()} Invites.get_invite!(id, current_user)
|> Invites.update_invite(%{"uses_left" => 0, "disabled_at" => now}, current_user)
|> case do
{:ok, %{name: invite_name}} ->
prompt = dgettext("prompts", "%{name} disabled succesfully", name: invite_name)
socket |> put_flash(:info, prompt) |> display_invites()
{:error, changeset} ->
socket |> put_flash(:error, changeset |> changeset_errors())
end
{:noreply, socket}
end end
# redisplays invites to socket defp display_invites(%{assigns: %{current_user: current_user}} = socket) do
defp display_invites(socket) do socket |> assign(:invites, Invites.list_invites(current_user))
invites = Invites.list_invites()
socket |> assign(:invites, invites)
end end
end end

View File

@ -69,7 +69,7 @@
<%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %> <%= if invite.disabled_at |> is_nil() and not(invite.uses_left |> is_nil()) do %>
<a href="#" class="btn btn-primary" <a href="#" class="btn btn-primary"
phx-click="set_unlimited" phx-value-id="<%= invite.id %>" phx-click="set_unlimited" phx-value-id="<%= invite.id %>"
data-confirm={dgettext("prompts", "Are you sure you want to make this invite unlimited?")}> data-confirm={dgettext("prompts", "Are you sure you want to make %{name} unlimited?", name: invite.name)}>
<%= gettext("Set Unlimited") %> <%= gettext("Set Unlimited") %>
</a> </a>
<% end %> <% end %>

View File

@ -91,11 +91,11 @@ msgid "New Ammo group"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:96 #: lib/cannery_web/live/ammo_group_live/form_component.ex:102
#: lib/cannery_web/live/ammo_type_live/form_component.ex:156 #: lib/cannery_web/live/ammo_type_live/form_component.ex:161
#: lib/cannery_web/live/container_live/form_component.ex:79 #: lib/cannery_web/live/container_live/form_component.ex:90
#: lib/cannery_web/live/invite_live/form_component.ex:61 #: lib/cannery_web/live/invite_live/form_component.ex:63
#: lib/cannery_web/live/tag_live/form_component.ex:62 #: lib/cannery_web/live/tag_live/form_component.ex:66
msgid "Save" msgid "Save"
msgstr "" msgstr ""

View File

@ -111,7 +111,7 @@ msgid "Settings"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:69 #: lib/cannery_web/live/ammo_group_live/form_component.ex:75
#: lib/cannery_web/live/ammo_group_live/index.html.heex:26 #: lib/cannery_web/live/ammo_group_live/index.html.heex:26
msgid "Count" msgid "Count"
msgstr "" msgstr ""
@ -144,7 +144,7 @@ msgid "No Ammo"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:83 #: lib/cannery_web/live/ammo_group_live/form_component.ex:89
#: lib/cannery_web/live/ammo_group_live/index.html.heex:32 #: lib/cannery_web/live/ammo_group_live/index.html.heex:32
msgid "Notes" msgid "Notes"
msgstr "" msgstr ""
@ -156,7 +156,7 @@ msgid "Notes:"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:76 #: lib/cannery_web/live/ammo_group_live/form_component.ex:82
#: lib/cannery_web/live/ammo_group_live/index.html.heex:29 #: lib/cannery_web/live/ammo_group_live/index.html.heex:29
msgid "Price paid" msgid "Price paid"
msgstr "" msgstr ""
@ -183,7 +183,7 @@ msgid "This ammo group is not in a container"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:63 #: lib/cannery_web/live/ammo_group_live/form_component.ex:69
msgid "Ammo type" msgid "Ammo type"
msgstr "" msgstr ""
@ -193,65 +193,65 @@ msgid "Average Price paid"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:140 #: lib/cannery_web/live/ammo_type_live/form_component.ex:145
#: lib/cannery_web/live/ammo_type_live/index.html.heex:38 #: lib/cannery_web/live/ammo_type_live/index.html.heex:38
msgid "Blank" msgid "Blank"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:102 #: lib/cannery_web/live/ammo_type_live/form_component.ex:107
msgid "Brass" msgid "Brass"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:78 #: lib/cannery_web/live/ammo_type_live/form_component.ex:83
#: lib/cannery_web/live/ammo_type_live/index.html.heex:28 #: lib/cannery_web/live/ammo_type_live/index.html.heex:28
#: lib/cannery_web/live/ammo_type_live/show.html.heex:37 #: lib/cannery_web/live/ammo_type_live/show.html.heex:37
msgid "Bullet core" msgid "Bullet core"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:71 #: lib/cannery_web/live/ammo_type_live/form_component.ex:76
#: lib/cannery_web/live/ammo_type_live/index.html.heex:27 #: lib/cannery_web/live/ammo_type_live/index.html.heex:27
#: lib/cannery_web/live/ammo_type_live/show.html.heex:36 #: lib/cannery_web/live/ammo_type_live/show.html.heex:36
msgid "Bullet type" msgid "Bullet type"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:92 #: lib/cannery_web/live/ammo_type_live/form_component.ex:97
#: lib/cannery_web/live/ammo_type_live/index.html.heex:30 #: lib/cannery_web/live/ammo_type_live/index.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:39 #: lib/cannery_web/live/ammo_type_live/show.html.heex:39
msgid "Caliber" msgid "Caliber"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:85 #: lib/cannery_web/live/ammo_type_live/form_component.ex:90
#: lib/cannery_web/live/ammo_type_live/index.html.heex:29 #: lib/cannery_web/live/ammo_type_live/index.html.heex:29
#: lib/cannery_web/live/ammo_type_live/show.html.heex:38 #: lib/cannery_web/live/ammo_type_live/show.html.heex:38
msgid "Cartridge" msgid "Cartridge"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:99 #: lib/cannery_web/live/ammo_type_live/form_component.ex:104
#: lib/cannery_web/live/ammo_type_live/index.html.heex:31 #: lib/cannery_web/live/ammo_type_live/index.html.heex:31
#: lib/cannery_web/live/ammo_type_live/show.html.heex:40 #: lib/cannery_web/live/ammo_type_live/show.html.heex:40
msgid "Case material" msgid "Case material"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:90 #: lib/cannery_web/live/ammo_group_live/form_component.ex:96
msgid "Container" msgid "Container"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:144 #: lib/cannery_web/live/ammo_type_live/form_component.ex:149
#: lib/cannery_web/live/ammo_type_live/index.html.heex:39 #: lib/cannery_web/live/ammo_type_live/index.html.heex:39
msgid "Corrosive" msgid "Corrosive"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:58 #: lib/cannery_web/live/ammo_type_live/form_component.ex:63
#: lib/cannery_web/live/container_live/form_component.ex:56 #: lib/cannery_web/live/container_live/form_component.ex:67
msgid "Description" msgid "Description"
msgstr "" msgstr ""
@ -262,24 +262,24 @@ msgid "Edit Ammo type"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:69 #: lib/cannery_web/live/ammo_type_live/form_component.ex:74
msgid "Example bullet type abbreviations" msgid "Example bullet type abbreviations"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:74 #: lib/cannery_web/live/ammo_type_live/form_component.ex:79
msgid "FMJ" msgid "FMJ"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:106 #: lib/cannery_web/live/ammo_type_live/form_component.ex:111
#: lib/cannery_web/live/ammo_type_live/index.html.heex:32 #: lib/cannery_web/live/ammo_type_live/index.html.heex:32
#: lib/cannery_web/live/ammo_type_live/show.html.heex:41 #: lib/cannery_web/live/ammo_type_live/show.html.heex:41
msgid "Grains" msgid "Grains"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:136 #: lib/cannery_web/live/ammo_type_live/form_component.ex:141
#: lib/cannery_web/live/ammo_type_live/index.html.heex:37 #: lib/cannery_web/live/ammo_type_live/index.html.heex:37
msgid "Incendiary" msgid "Incendiary"
msgstr "" msgstr ""
@ -295,17 +295,17 @@ msgid "Listing Ammo types"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:148 #: lib/cannery_web/live/ammo_type_live/form_component.ex:153
#: lib/cannery_web/live/ammo_type_live/index.html.heex:40 #: lib/cannery_web/live/ammo_type_live/index.html.heex:40
msgid "Manufacturer" msgid "Manufacturer"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:54 #: lib/cannery_web/live/ammo_type_live/form_component.ex:59
#: lib/cannery_web/live/ammo_type_live/index.html.heex:26 #: lib/cannery_web/live/ammo_type_live/index.html.heex:26
#: lib/cannery_web/live/container_live/form_component.ex:49 #: lib/cannery_web/live/container_live/form_component.ex:60
#: lib/cannery_web/live/invite_live/form_component.ex:53 #: lib/cannery_web/live/invite_live/form_component.ex:55
#: lib/cannery_web/live/tag_live/form_component.ex:46 #: lib/cannery_web/live/tag_live/form_component.ex:50
msgid "Name" msgid "Name"
msgstr "" msgstr ""
@ -325,27 +325,27 @@ msgid "No ammo for this type"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:114 #: lib/cannery_web/live/ammo_type_live/form_component.ex:119
#: lib/cannery_web/live/ammo_type_live/index.html.heex:33 #: lib/cannery_web/live/ammo_type_live/index.html.heex:33
#: lib/cannery_web/live/ammo_type_live/show.html.heex:42 #: lib/cannery_web/live/ammo_type_live/show.html.heex:42
msgid "Pressure" msgid "Pressure"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:121 #: lib/cannery_web/live/ammo_type_live/form_component.ex:126
#: lib/cannery_web/live/ammo_type_live/index.html.heex:34 #: lib/cannery_web/live/ammo_type_live/index.html.heex:34
#: lib/cannery_web/live/ammo_type_live/show.html.heex:43 #: lib/cannery_web/live/ammo_type_live/show.html.heex:43
msgid "Primer type" msgid "Primer type"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:128 #: lib/cannery_web/live/ammo_type_live/form_component.ex:133
#: lib/cannery_web/live/ammo_type_live/index.html.heex:35 #: lib/cannery_web/live/ammo_type_live/index.html.heex:35
msgid "Rimfire" msgid "Rimfire"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:152 #: lib/cannery_web/live/ammo_type_live/form_component.ex:157
msgid "SKU" msgid "SKU"
msgstr "" msgstr ""
@ -360,12 +360,12 @@ msgid "Sku"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:81 #: lib/cannery_web/live/ammo_type_live/form_component.ex:86
msgid "Steel" msgid "Steel"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:132 #: lib/cannery_web/live/ammo_type_live/form_component.ex:137
#: lib/cannery_web/live/ammo_type_live/index.html.heex:36 #: lib/cannery_web/live/ammo_type_live/index.html.heex:36
msgid "Tracer" msgid "Tracer"
msgstr "" msgstr ""
@ -377,19 +377,19 @@ msgid "Description:"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:22 #: lib/cannery_web/live/container_live/index.ex:23
#: lib/cannery_web/live/container_live/show.ex:58 #: lib/cannery_web/live/container_live/show.ex:67
msgid "Edit Container" msgid "Edit Container"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:34 #: lib/cannery_web/live/container_live/index.ex:32
#: lib/cannery_web/live/container_live/index.html.heex:3 #: lib/cannery_web/live/container_live/index.html.heex:3
msgid "Listing Containers" msgid "Listing Containers"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:71 #: lib/cannery_web/live/container_live/form_component.ex:82
msgid "Location" msgid "Location"
msgstr "" msgstr ""
@ -400,17 +400,17 @@ msgid "Location:"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:67 #: lib/cannery_web/live/container_live/form_component.ex:78
msgid "Magazine, Clip, Ammo Box, etc" msgid "Magazine, Clip, Ammo Box, etc"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:60 #: lib/cannery_web/live/container_live/form_component.ex:71
msgid "Metal ammo can with the anime girl sticker" msgid "Metal ammo can with the anime girl sticker"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:52 #: lib/cannery_web/live/container_live/form_component.ex:63
msgid "My cool ammo can" msgid "My cool ammo can"
msgstr "" msgstr ""
@ -430,17 +430,17 @@ msgid "No containers"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:75 #: lib/cannery_web/live/container_live/form_component.ex:86
msgid "On the bookshelf" msgid "On the bookshelf"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/show.ex:57 #: lib/cannery_web/live/container_live/show.ex:66
msgid "Show Container" msgid "Show Container"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:64 #: lib/cannery_web/live/container_live/form_component.ex:75
msgid "Type" msgid "Type"
msgstr "" msgstr ""
@ -451,7 +451,7 @@ msgid "Type:"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/tag_live/form_component.ex:50 #: lib/cannery_web/live/tag_live/form_component.ex:54
msgid "Background color" msgid "Background color"
msgstr "" msgstr ""
@ -481,7 +481,7 @@ msgid "Invite Disabled"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:33 #: lib/cannery_web/live/invite_live/index.ex:31
#: lib/cannery_web/live/invite_live/index.html.leex:3 #: lib/cannery_web/live/invite_live/index.html.leex:3
msgid "Listing Invites" msgid "Listing Invites"
msgstr "" msgstr ""
@ -493,7 +493,7 @@ msgid "Listing Tags"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:28 #: lib/cannery_web/live/invite_live/index.ex:27
msgid "New Invite" msgid "New Invite"
msgstr "" msgstr ""
@ -523,7 +523,7 @@ msgid "Tags can be added to your containers to help you organize"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/tag_live/form_component.ex:56 #: lib/cannery_web/live/tag_live/form_component.ex:60
msgid "Text color" msgid "Text color"
msgstr "" msgstr ""
@ -533,6 +533,6 @@ msgid "Uses Left:"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/form_component.ex:57 #: lib/cannery_web/live/invite_live/form_component.ex:59
msgid "Uses left" msgid "Uses left"
msgstr "" msgstr ""

View File

@ -138,13 +138,6 @@ msgstr ""
msgid "Go back home" msgid "Go back home"
msgstr "" msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery/containers.ex:105
msgid "There is still %{amount} ammo group in this container"
msgid_plural "There are still %{amount} ammo groups in this container"
msgstr[0] ""
msgstr[1] ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/templates/user_registration/new.html.heex:13 #: lib/cannery_web/templates/user_registration/new.html.heex:13
#: lib/cannery_web/templates/user_reset_password/edit.html.heex:13 #: lib/cannery_web/templates/user_reset_password/edit.html.heex:13
@ -201,12 +194,17 @@ msgid "You must log in to access this page."
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:65 #: lib/cannery_web/live/container_live/index.ex:42
#: lib/cannery_web/live/container_live/show.ex:47 msgid "Could not find that container"
msgid "Could not delete container: %{error}"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:45 #: lib/cannery/containers.ex:105
msgid "Could not find that container" msgid "Container must be empty before deleting"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:54
#: lib/cannery_web/live/container_live/show.ex:52
msgid "Could not delete %{name}: %{error}"
msgstr "" msgstr ""

View File

@ -77,12 +77,12 @@ msgid "Your account has been deleted"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:145 #: lib/cannery_web/live/ammo_group_live/form_component.ex:151
msgid "Ammo group created successfully" msgid "Ammo group created successfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:127 #: lib/cannery_web/live/ammo_group_live/form_component.ex:133
msgid "Ammo group updated successfully" msgid "Ammo group updated successfully"
msgstr "" msgstr ""
@ -94,11 +94,11 @@ msgid "Are you sure you want to delete this ammo?"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/form_component.ex:97 #: lib/cannery_web/live/ammo_group_live/form_component.ex:103
#: lib/cannery_web/live/ammo_type_live/form_component.ex:157 #: lib/cannery_web/live/ammo_type_live/form_component.ex:162
#: lib/cannery_web/live/container_live/form_component.ex:81 #: lib/cannery_web/live/container_live/form_component.ex:92
#: lib/cannery_web/live/invite_live/form_component.ex:63 #: lib/cannery_web/live/invite_live/form_component.ex:65
#: lib/cannery_web/live/tag_live/form_component.ex:64 #: lib/cannery_web/live/tag_live/form_component.ex:68
msgid "Saving..." msgid "Saving..."
msgstr "" msgstr ""
@ -111,52 +111,37 @@ msgid "Are you sure you want to delete %{name}?"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/index.ex:55 #: lib/cannery_web/live/container_live/index.ex:47
#: lib/cannery_web/live/container_live/show.ex:37 #: lib/cannery_web/live/container_live/show.ex:42
msgid "%{name} has been deleted" msgid "%{name} has been deleted"
msgstr "" msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:113
msgid "Container created successfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/form_component.ex:98
msgid "Container updated successfully"
msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.html.leex:53 #: lib/cannery_web/live/invite_live/index.html.leex:53
msgid "Are you sure you want to delete the invite for %{name}?" msgid "Are you sure you want to delete the invite for %{name}?"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/form_component.ex:88 #: lib/cannery_web/live/ammo_type_live/form_component.ex:193
msgid "Invite created successfully" #: lib/cannery_web/live/container_live/form_component.ex:126
msgstr "" #: lib/cannery_web/live/invite_live/form_component.ex:98
#: lib/cannery_web/live/tag_live/form_component.ex:101
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/form_component.ex:75
msgid "Invite updated successfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:188
#: lib/cannery_web/live/tag_live/form_component.ex:97
msgid "%{name} created successfully" msgid "%{name} created successfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:41 #: lib/cannery_web/live/ammo_type_live/index.ex:41
#: lib/cannery_web/live/ammo_type_live/show.ex:39 #: lib/cannery_web/live/ammo_type_live/show.ex:39
#: lib/cannery_web/live/invite_live/index.ex:39
#: lib/cannery_web/live/tag_live/index.ex:41 #: lib/cannery_web/live/tag_live/index.ex:41
msgid "%{name} deleted succesfully" msgid "%{name} deleted succesfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen #, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/form_component.ex:174 #: lib/cannery_web/live/ammo_type_live/form_component.ex:179
#: lib/cannery_web/live/tag_live/form_component.ex:79 #: lib/cannery_web/live/container_live/form_component.ex:108
#: lib/cannery_web/live/invite_live/form_component.ex:80
#: lib/cannery_web/live/tag_live/form_component.ex:83
msgid "%{name} updated successfully" msgid "%{name} updated successfully"
msgstr "" msgstr ""
@ -165,3 +150,18 @@ msgstr ""
#: lib/cannery_web/live/ammo_group_live/show.ex:33 #: lib/cannery_web/live/ammo_group_live/show.ex:33
msgid "Ammo group deleted succesfully" msgid "Ammo group deleted succesfully"
msgstr "" msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:87
msgid "%{name} disabled succesfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:69
msgid "%{name} enabled succesfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:53
msgid "%{name} updated succesfully"
msgstr ""