Editable info paragraphs.
This commit is contained in:
67
lib/runosaari_web/controllers/info_controller.ex
Normal file
67
lib/runosaari_web/controllers/info_controller.ex
Normal file
@@ -0,0 +1,67 @@
|
||||
defmodule RunosaariWeb.InfoController do
|
||||
use RunosaariWeb, :controller
|
||||
|
||||
alias Runosaari.Pages
|
||||
alias Runosaari.Pages.Info
|
||||
|
||||
def index(conn, _params) do
|
||||
info_paragraphs = Pages.list_sorted_info_paragraphs()
|
||||
render(conn, "index.html", info_paragraphs: info_paragraphs)
|
||||
end
|
||||
|
||||
def admin(conn, _params) do
|
||||
info_paragraphs = Pages.list_info_paragraphs()
|
||||
render(conn, "admin.html", info_paragraphs: info_paragraphs)
|
||||
end
|
||||
|
||||
def new(conn, _params) do
|
||||
changeset = Pages.change_info(%Info{})
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
def create(conn, %{"info" => info_params}) do
|
||||
case Pages.create_info(info_params) do
|
||||
{:ok, info} ->
|
||||
conn
|
||||
|> put_flash(:info, "Info created successfully.")
|
||||
|> redirect(to: Routes.admin_info_path(conn, :admin))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
info = Pages.get_info!(id)
|
||||
render(conn, "show.html", info: info)
|
||||
end
|
||||
|
||||
def edit(conn, %{"id" => id}) do
|
||||
info = Pages.get_info!(id)
|
||||
changeset = Pages.change_info(info)
|
||||
render(conn, "edit.html", info: info, changeset: changeset)
|
||||
end
|
||||
|
||||
def update(conn, %{"id" => id, "info" => info_params}) do
|
||||
info = Pages.get_info!(id)
|
||||
|
||||
case Pages.update_info(info, info_params) do
|
||||
{:ok, info} ->
|
||||
conn
|
||||
|> put_flash(:info, "Info updated successfully.")
|
||||
|> redirect(to: Routes.admin_info_path(conn, :show, info))
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
render(conn, "edit.html", info: info, changeset: changeset)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(conn, %{"id" => id}) do
|
||||
info = Pages.get_info!(id)
|
||||
{:ok, _info} = Pages.delete_info(info)
|
||||
|
||||
conn
|
||||
|> put_flash(:info, "Info deleted successfully.")
|
||||
|> redirect(to: Routes.admin_info_path(conn, :admin))
|
||||
end
|
||||
end
|
||||
@@ -17,13 +17,13 @@ defmodule RunosaariWeb.Router do
|
||||
pipe_through :browser
|
||||
|
||||
resources "/", IndexController, only: [:index]
|
||||
get "/info", PageController, :info
|
||||
get "/covid19", PageController, :covid19
|
||||
get "/privacy", PageController, :privacy
|
||||
resources "/performers", PerformerController, only: [:index, :show]
|
||||
resources "/performances", PerformanceController, only: [:index]
|
||||
resources "/visitors", VisitorController, only: [:new, :create]
|
||||
get "/confirmation", VisitorController, :confirmation
|
||||
resources "/info", InfoController, only: [:index]
|
||||
end
|
||||
|
||||
scope "/admin", RunosaariWeb, as: :admin do
|
||||
@@ -36,6 +36,8 @@ defmodule RunosaariWeb.Router do
|
||||
resources "/performers", PerformerController, except: [:index, :show]
|
||||
resources "/performances", PerformanceController, except: [:index]
|
||||
resources "/visitors", VisitorController, except: [:new, :create]
|
||||
resources "/info", InfoController, except: [:index]
|
||||
get "/info", InfoController, :admin
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<section class="main">
|
||||
<h1>HALLINTA - Etusivu</h1>
|
||||
<h1>HALLINTA - Etusivu<n kappaleet/h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
@@ -19,12 +19,12 @@
|
||||
<td class="actions">
|
||||
<span><%= link "Lisätietoja", to: Routes.admin_index_path(@conn, :show, index) %></span>
|
||||
<span><%= link "Muokkaa", to: Routes.admin_index_path(@conn, :edit, index) %></span>
|
||||
<span><%= link "Poista", to: Routes.admin_index_path(@conn, :delete, index), method: :delete, data: [confirm: "Are you sure?"] %></span>
|
||||
<span><%= link "Poista", to: Routes.admin_index_path(@conn, :delete, index), method: :delete, data: [confirm: "Oletko varma?"] %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<span><%= link "Uusi Kappale", to: Routes.admin_index_path(@conn, :new) %></span>
|
||||
<span><%= link "Uusi kappale", to: Routes.admin_index_path(@conn, :new) %></span>
|
||||
</section>
|
||||
|
||||
30
lib/runosaari_web/templates/info/admin.html.eex
Normal file
30
lib/runosaari_web/templates/info/admin.html.eex
Normal file
@@ -0,0 +1,30 @@
|
||||
<section class="main">
|
||||
<h1>HALLINTA - Infon kappaleet</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sisältö</th>
|
||||
<th>Prioriteetti</th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for info <- @info_paragraphs do %>
|
||||
<tr>
|
||||
<td><%= info.content %></td>
|
||||
<td><%= info.seqnum %></td>
|
||||
|
||||
<td class="actions">
|
||||
<span><%= link "Lisätietoja", to: Routes.admin_info_path(@conn, :show, info) %></span>
|
||||
<span><%= link "Muokkaa", to: Routes.admin_info_path(@conn, :edit, info) %></span>
|
||||
<span><%= link "Poista", to: Routes.admin_info_path(@conn, :delete, info), method: :delete, data: [confirm: "Oletko varma?"] %></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<span><%= link "Uusi kappale", to: Routes.admin_info_path(@conn, :new) %></span>
|
||||
</section>
|
||||
5
lib/runosaari_web/templates/info/edit.html.eex
Normal file
5
lib/runosaari_web/templates/info/edit.html.eex
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>Muokkaa kappaletta</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.admin_info_path(@conn, :update, @info)) %>
|
||||
|
||||
<span><%= link "Takaisin", to: Routes.admin_info_path(@conn, :admin) %></span>
|
||||
19
lib/runosaari_web/templates/info/form.html.eex
Normal file
19
lib/runosaari_web/templates/info/form.html.eex
Normal file
@@ -0,0 +1,19 @@
|
||||
<%= form_for @changeset, @action, fn f -> %>
|
||||
<%= if @changeset.action do %>
|
||||
<div class="alert alert-danger">
|
||||
<p>Jokin kentistä on tyhjä.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= label f, :content, "Sisältö" %>
|
||||
<%= text_input f, :content %>
|
||||
<%= error_tag f, :content %>
|
||||
|
||||
<%= label f, :seqnum, "Prioritetti (1 on korkein)" %>
|
||||
<%= number_input f, :seqnum %>
|
||||
<%= error_tag f, :seqnum %>
|
||||
|
||||
<div>
|
||||
<%= submit "Tallenna" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -9,18 +9,9 @@
|
||||
Kirjan talo – Bokens hus ry, Livonsaaren kyläyhdistys ry ja
|
||||
Saaristohotelli Vaihela.
|
||||
</p>
|
||||
<p>
|
||||
Tapahtuma tuo korkeatasoista kotimaista runoutta helposti
|
||||
lähestyttävässä muodossa maaseudun uusille yleisöille, niin
|
||||
paikallisille saaristolaisille kuin mökkiläisille, kutsuvieraille ja
|
||||
kauempaa tulleillekin. Samalla se voimistaa paikallista
|
||||
yhteisöllisyyttä ja taiteen tekemistä ja kokemista vaikeina
|
||||
korona-aikoina.
|
||||
</p>
|
||||
<p>
|
||||
Esitykset striimataan Suomeen ja mahdollisesti myös kansainvälisten
|
||||
yhteistyökumppanien sivuille.
|
||||
</p>
|
||||
<%= for info <- @info_paragraphs do %>
|
||||
<p><%= info.content %></p>
|
||||
<% end %>
|
||||
<p>
|
||||
<b><i>Ota yhteyttä:</i></b> Inkeri Aula & Katariina Vuorinen,
|
||||
<a class="generic-link" href="mailto:info@runosaari.net">info@runosaari.net</a>
|
||||
5
lib/runosaari_web/templates/info/new.html.eex
Normal file
5
lib/runosaari_web/templates/info/new.html.eex
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New Info</h1>
|
||||
|
||||
<%= render "form.html", Map.put(assigns, :action, Routes.admin_info_path(@conn, :create)) %>
|
||||
|
||||
<span><%= link "Back", to: Routes.admin_info_path(@conn, :admin) %></span>
|
||||
20
lib/runosaari_web/templates/info/show.html.eex
Normal file
20
lib/runosaari_web/templates/info/show.html.eex
Normal file
@@ -0,0 +1,20 @@
|
||||
<section class="main">
|
||||
<h1>Kappaleen tiedot</h1>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<strong>Sisältö:</strong>
|
||||
<%= @info.content %>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<strong>Prioriteetti:</strong>
|
||||
<%= @info.seqnum %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<span><%= link "Muokkaa", to: Routes.admin_info_path(@conn, :edit, @info) %></span>
|
||||
<span><%= link "Takaisin", to: Routes.admin_info_path(@conn, :admin) %></span>
|
||||
</section>
|
||||
@@ -19,7 +19,7 @@
|
||||
<%= link "Etusivu", to: Routes.index_path(@conn, :index) %>
|
||||
<%= link "Ohjelma", to: Routes.performance_path(@conn, :index) %>
|
||||
<%= link "Esiintyjät", to: Routes.performer_path(@conn, :index) %>
|
||||
<%= link "Info", to: Routes.page_path(@conn, :info) %>
|
||||
<%= link "Info", to: Routes.info_path(@conn, :index) %>
|
||||
<%= link "Covid-19", to: Routes.page_path(@conn, :covid19) %>
|
||||
<%= link "Ilmoittautuminen", to: Routes.visitor_path(@conn, :new) %>
|
||||
</nav>
|
||||
@@ -30,7 +30,7 @@
|
||||
<%= link "Etusivu", to: "#{Routes.index_path(@conn, :index)}#logo-start" %>
|
||||
<%= link "Ohjelma", to: "#{Routes.performance_path(@conn, :index)}#calendar-start" %>
|
||||
<%= link "Esiintyjät", to: "#{Routes.performer_path(@conn, :index)}#performers-start" %>
|
||||
<%= link "Info", to: "#{Routes.page_path(@conn, :info)}#contact-start" %>
|
||||
<%= link "Info", to: "#{Routes.info_path(@conn, :index )}#contact-start" %>
|
||||
<%= link "Covid-19", to: "#{Routes.page_path(@conn, :covid19)}#covid-start" %>
|
||||
<%= link "Ilmoittautuminen", to: "#{Routes.visitor_path(@conn, :new)}#registration-start" %>
|
||||
</nav>
|
||||
|
||||
3
lib/runosaari_web/views/info_view.ex
Normal file
3
lib/runosaari_web/views/info_view.ex
Normal file
@@ -0,0 +1,3 @@
|
||||
defmodule RunosaariWeb.InfoView do
|
||||
use RunosaariWeb, :view
|
||||
end
|
||||
Reference in New Issue
Block a user