diff --git a/lib/runosaari/registration.ex b/lib/runosaari/registration.ex
index 12d314c..ebf8899 100644
--- a/lib/runosaari/registration.ex
+++ b/lib/runosaari/registration.ex
@@ -33,6 +33,24 @@ defmodule Runosaari.Registration do
def list_sorted_confirmed_performers do
Performer
|> where([p], p.confirmed == true)
+ |> where([p], is_nil(p.archived))
+ |> order_by(:name)
+ |> Repo.all()
+ end
+
+ @doc """
+ Returns the :name sorted list of archived performers by year.
+
+ ## Examples
+
+ iex> list_sorted_confirmed_performers()
+ [%Performer{}, ...]
+
+ """
+ def list_sorted_archived_performers(year) do
+ Performer
+ |> where([p], not is_nil(p.archived))
+ |> where([p], p.archived == ^year)
|> order_by(:name)
|> Repo.all()
end
diff --git a/lib/runosaari/registration/performer.ex b/lib/runosaari/registration/performer.ex
index 66a8028..789e698 100644
--- a/lib/runosaari/registration/performer.ex
+++ b/lib/runosaari/registration/performer.ex
@@ -12,6 +12,7 @@ defmodule Runosaari.Registration.Performer do
field :link, :string
field :photo_path, :string
field :confirmed, :boolean, default: false
+ field :archived, :integer
timestamps()
end
@@ -28,7 +29,8 @@ defmodule Runosaari.Registration.Performer do
:paragraph5,
:link,
:photo_path,
- :confirmed
+ :confirmed,
+ :archived
])
|> validate_required([
:name,
diff --git a/lib/runosaari/schedule.ex b/lib/runosaari/schedule.ex
index 378dfda..4915f24 100644
--- a/lib/runosaari/schedule.ex
+++ b/lib/runosaari/schedule.ex
@@ -31,7 +31,7 @@ defmodule Runosaari.Schedule do
"""
def list_sorted_performances do
- Repo.all(Performance |> order_by(:seqnum))
+ Repo.all(Performance |> where([p], not is_nil(p.seqnum)) |> order_by(:seqnum))
end
@doc """
diff --git a/lib/runosaari_web/controllers/archive_controller.ex b/lib/runosaari_web/controllers/archive_controller.ex
new file mode 100644
index 0000000..1d25efd
--- /dev/null
+++ b/lib/runosaari_web/controllers/archive_controller.ex
@@ -0,0 +1,10 @@
+defmodule RunosaariWeb.ArchiveController do
+ use RunosaariWeb, :controller
+
+ alias Runosaari.Registration
+
+ def index(conn, _params) do
+ performers2021 = Registration.list_sorted_archived_performers(2021)
+ render(conn, "index.html", performers2021: performers2021)
+ end
+end
diff --git a/lib/runosaari_web/router.ex b/lib/runosaari_web/router.ex
index 102f174..70b9eed 100644
--- a/lib/runosaari_web/router.ex
+++ b/lib/runosaari_web/router.ex
@@ -16,14 +16,15 @@ defmodule RunosaariWeb.Router do
scope "/", RunosaariWeb do
pipe_through :browser
- resources "/", IndexController, only: [:index]
+ get "/", IndexController, :index
get "/safety", PageController, :safety
get "/privacy", PageController, :privacy
resources "/performers", PerformerController, only: [:index, :show]
- resources "/performances", PerformanceController, only: [:index]
+ get "/performances", PerformanceController, :index
resources "/visitors", VisitorController, only: [:new, :create]
get "/confirmation", VisitorController, :confirmation
- resources "/info", InfoController, only: [:index]
+ get "/info", InfoController, :index
+ get "/archive", ArchiveController, :index
end
scope "/admin", RunosaariWeb, as: :admin do
diff --git a/lib/runosaari_web/templates/archive/index.html.eex b/lib/runosaari_web/templates/archive/index.html.eex
new file mode 100644
index 0000000..9d22b56
--- /dev/null
+++ b/lib/runosaari_web/templates/archive/index.html.eex
@@ -0,0 +1,12 @@
+Arkisto
+
+