Improve logic and add working "delete" links

This commit is contained in:
Thelonius Kort
2023-02-14 21:02:48 +01:00
parent 7297a907da
commit faf2bb0e2e
8 changed files with 45 additions and 39 deletions

View File

@ -8,8 +8,13 @@ defmodule OutlookWeb.ArtikelController do
render(conn, :index, artikel: artikel, page_title: "Artikel")
end
def show(conn, %{"id" => id}) do
artikel = Artikel.get_artikel!(id)
render(conn, :show, artikel: artikel, page_title: artikel.title)
def show(conn, %{"tid" => tid} = params) do
case Artikel.get_artikel_by_tid(tid) do
{:ok, artikel} -> render(conn, :show, artikel: artikel, page_title: artikel.title)
{:error, message} -> conn
|> put_status(404)
|> render(OutlookWeb.ErrorHTML, "404.html")
|> halt()
end
end
end