Archive page
This commit is contained in:
@@ -33,6 +33,24 @@ defmodule Runosaari.Registration do
|
|||||||
def list_sorted_confirmed_performers do
|
def list_sorted_confirmed_performers do
|
||||||
Performer
|
Performer
|
||||||
|> where([p], p.confirmed == true)
|
|> 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)
|
|> order_by(:name)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ defmodule Runosaari.Registration.Performer do
|
|||||||
field :link, :string
|
field :link, :string
|
||||||
field :photo_path, :string
|
field :photo_path, :string
|
||||||
field :confirmed, :boolean, default: false
|
field :confirmed, :boolean, default: false
|
||||||
|
field :archived, :integer
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
@@ -28,7 +29,8 @@ defmodule Runosaari.Registration.Performer do
|
|||||||
:paragraph5,
|
:paragraph5,
|
||||||
:link,
|
:link,
|
||||||
:photo_path,
|
:photo_path,
|
||||||
:confirmed
|
:confirmed,
|
||||||
|
:archived
|
||||||
])
|
])
|
||||||
|> validate_required([
|
|> validate_required([
|
||||||
:name,
|
:name,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ defmodule Runosaari.Schedule do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
def list_sorted_performances 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
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|||||||
10
lib/runosaari_web/controllers/archive_controller.ex
Normal file
10
lib/runosaari_web/controllers/archive_controller.ex
Normal file
@@ -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
|
||||||
@@ -16,14 +16,15 @@ defmodule RunosaariWeb.Router do
|
|||||||
scope "/", RunosaariWeb do
|
scope "/", RunosaariWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
resources "/", IndexController, only: [:index]
|
get "/", IndexController, :index
|
||||||
get "/safety", PageController, :safety
|
get "/safety", PageController, :safety
|
||||||
get "/privacy", PageController, :privacy
|
get "/privacy", PageController, :privacy
|
||||||
resources "/performers", PerformerController, only: [:index, :show]
|
resources "/performers", PerformerController, only: [:index, :show]
|
||||||
resources "/performances", PerformanceController, only: [:index]
|
get "/performances", PerformanceController, :index
|
||||||
resources "/visitors", VisitorController, only: [:new, :create]
|
resources "/visitors", VisitorController, only: [:new, :create]
|
||||||
get "/confirmation", VisitorController, :confirmation
|
get "/confirmation", VisitorController, :confirmation
|
||||||
resources "/info", InfoController, only: [:index]
|
get "/info", InfoController, :index
|
||||||
|
get "/archive", ArchiveController, :index
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/admin", RunosaariWeb, as: :admin do
|
scope "/admin", RunosaariWeb, as: :admin do
|
||||||
|
|||||||
12
lib/runosaari_web/templates/archive/index.html.eex
Normal file
12
lib/runosaari_web/templates/archive/index.html.eex
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<section class="main">
|
||||||
|
<h1 id="archive-start">Arkisto</h1>
|
||||||
|
|
||||||
|
<div class="performers2021-container">
|
||||||
|
<%= for performer <- @performers2021 do %>
|
||||||
|
<div class="performer-name">
|
||||||
|
<span class="fa fa-chevron-right" ></span>
|
||||||
|
<%= link "#{performer.name}", to: "#{Routes.performer_path(@conn, :show, performer)}#performer-start" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<%= link "Esiintyjät", to: Routes.performer_path(@conn, :index) %>
|
<%= link "Esiintyjät", to: Routes.performer_path(@conn, :index) %>
|
||||||
<%= link "Info", to: Routes.info_path(@conn, :index) %>
|
<%= link "Info", to: Routes.info_path(@conn, :index) %>
|
||||||
<%= link "Turvallisuus", to: Routes.page_path(@conn, :safety) %>
|
<%= link "Turvallisuus", to: Routes.page_path(@conn, :safety) %>
|
||||||
<%= link "Ilmoittautuminen", to: Routes.visitor_path(@conn, :new) %>
|
<%= link "Arkisto", to: Routes.archive_path(@conn, :index) %>
|
||||||
</nav>
|
</nav>
|
||||||
<h1 class="mobile-main-title">
|
<h1 class="mobile-main-title">
|
||||||
<a href="/#logo-container">Runosaari 2021</a>
|
<a href="/#logo-container">Runosaari 2021</a>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<%= link "Esiintyjät", to: "#{Routes.performer_path(@conn, :index)}#performers-start" %>
|
<%= link "Esiintyjät", to: "#{Routes.performer_path(@conn, :index)}#performers-start" %>
|
||||||
<%= link "Info", to: "#{Routes.info_path(@conn, :index )}#contact-start" %>
|
<%= link "Info", to: "#{Routes.info_path(@conn, :index )}#contact-start" %>
|
||||||
<%= link "Turvallisuus", to: "#{Routes.page_path(@conn, :safety)}#safety-start" %>
|
<%= link "Turvallisuus", to: "#{Routes.page_path(@conn, :safety)}#safety-start" %>
|
||||||
<%= link "Ilmoittautuminen", to: "#{Routes.visitor_path(@conn, :new)}#registration-start" %>
|
<%= link "Arkisto", to: "#{Routes.archive_path(@conn, :index)}#archive-start" %>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main role="main">
|
<main role="main">
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<%= error_tag form, :paragraph9 %>
|
<%= error_tag form, :paragraph9 %>
|
||||||
|
|
||||||
<%= label form, :seqnum, "Prioriteetti (1 on korkein)" %>
|
<%= label form, :seqnum, "Prioriteetti (1 on korkein)" %>
|
||||||
<%= textarea form, :seqnum %>
|
<%= number_input form, :seqnum %>
|
||||||
<%= error_tag form, :seqnum %>
|
<%= error_tag form, :seqnum %>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
<%= error_tag form, :confirmed %>
|
<%= error_tag form, :confirmed %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= label form, :seqnum, "Arkistoitu (vuosi). Jätä tyhjäksi jos tulee näkyä Esiintyjät-sivulla." %>
|
||||||
|
<%= number_input form, :seqnum %>
|
||||||
|
<%= error_tag form, :seqnum %>
|
||||||
|
|
||||||
<div class="submit-button">
|
<div class="submit-button">
|
||||||
<%= submit "Tallenna" %>
|
<%= submit "Tallenna" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
3
lib/runosaari_web/views/archive_view.ex
Normal file
3
lib/runosaari_web/views/archive_view.ex
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
defmodule RunosaariWeb.ArchiveView do
|
||||||
|
use RunosaariWeb, :view
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user