Fix resource name for fp ban controller

This commit is contained in:
Liam 2024-06-16 09:13:25 -04:00
parent 19eb5be999
commit 9f031725ac
2 changed files with 10 additions and 5 deletions

View file

@ -7,7 +7,12 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
import Ecto.Query import Ecto.Query
plug :verify_authorized plug :verify_authorized
plug :load_resource, model: FingerprintBan, only: [:edit, :update, :delete]
plug :load_resource,
model: FingerprintBan,
as: :fingerprint_ban,
only: [:edit, :update, :delete]
plug :check_can_delete when action in [:delete] plug :check_can_delete when action in [:delete]
def index(conn, %{"q" => q}) when is_binary(q) do def index(conn, %{"q" => q}) when is_binary(q) do
@ -56,12 +61,12 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
end end
def edit(conn, _params) do def edit(conn, _params) do
changeset = Bans.change_fingerprint(conn.assigns.fingerprint) changeset = Bans.change_fingerprint(conn.assigns.fingerprint_ban)
render(conn, "edit.html", title: "Editing Fingerprint Ban", changeset: changeset) render(conn, "edit.html", title: "Editing Fingerprint Ban", changeset: changeset)
end end
def update(conn, %{"fingerprint" => fingerprint_ban_params}) do def update(conn, %{"fingerprint" => fingerprint_ban_params}) do
case Bans.update_fingerprint(conn.assigns.fingerprint, fingerprint_ban_params) do case Bans.update_fingerprint(conn.assigns.fingerprint_ban, fingerprint_ban_params) do
{:ok, fingerprint_ban} -> {:ok, fingerprint_ban} ->
conn conn
|> put_flash(:info, "Fingerprint ban successfully updated.") |> put_flash(:info, "Fingerprint ban successfully updated.")
@ -74,7 +79,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do
end end
def delete(conn, _params) do def delete(conn, _params) do
{:ok, fingerprint_ban} = Bans.delete_fingerprint(conn.assigns.fingerprint) {:ok, fingerprint_ban} = Bans.delete_fingerprint(conn.assigns.fingerprint_ban)
conn conn
|> put_flash(:info, "Fingerprint ban successfully deleted.") |> put_flash(:info, "Fingerprint ban successfully deleted.")

View file

@ -1,6 +1,6 @@
h1 Editing ban h1 Editing ban
= render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: ~p"/admin/fingerprint_bans/#{@fingerprint}", conn: @conn = render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: ~p"/admin/fingerprint_bans/#{@fingerprint_ban}", conn: @conn
br br
= link "Back", to: ~p"/admin/fingerprint_bans" = link "Back", to: ~p"/admin/fingerprint_bans"