Add autoren and artikel for public viewing

This commit is contained in:
Thelonius Kort
2023-01-19 11:25:14 +01:00
parent aab04f5ecc
commit a93afea57b
12 changed files with 175 additions and 2 deletions

21
lib/outlook/artikel.ex Normal file
View File

@ -0,0 +1,21 @@
defmodule Outlook.Artikel do
@moduledoc """
The Artikel context.
"""
alias Outlook.Translations.Translation
import Ecto.Query, warn: false
alias Outlook.Repo
def list_artikel do
Repo.all(from t in Translation, where: t.public == true)
|> Repo.preload([article: :author])
end
def get_artikel!(artikel) when is_struct(artikel), do: get_artikel!(artikel.id)
def get_artikel!(id) do
Repo.one(from t in Translation, where: t.id == ^id and t.public == true)
|> Repo.preload([article: :author])
end
end