diff --git a/lib/runosaari_web/controllers/visitor_controller.ex b/lib/runosaari_web/controllers/visitor_controller.ex
index 8523c82..027a0f2 100644
--- a/lib/runosaari_web/controllers/visitor_controller.ex
+++ b/lib/runosaari_web/controllers/visitor_controller.ex
@@ -18,8 +18,7 @@ defmodule RunosaariWeb.VisitorController do
case Registration.create_visitor(visitor_params) do
{:ok, visitor} ->
conn
- |> put_flash(:info, "Visitor created successfully.")
- |> redirect(to: Routes.visitor_path(conn, :show, visitor))
+ |> redirect(to: Routes.visitor_path(conn, :confirmation))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
@@ -59,4 +58,8 @@ defmodule RunosaariWeb.VisitorController do
|> put_flash(:info, "Visitor deleted successfully.")
|> redirect(to: Routes.visitor_path(conn, :index))
end
+
+ def confirmation(conn, _params) do
+ render(conn, "confirmation.html")
+ end
end
diff --git a/lib/runosaari_web/router.ex b/lib/runosaari_web/router.ex
index 6d405cf..7469d01 100644
--- a/lib/runosaari_web/router.ex
+++ b/lib/runosaari_web/router.ex
@@ -21,6 +21,8 @@ defmodule RunosaariWeb.Router do
get "/covid19", PageController, :covid19
resources "/performers", PerformerController, only: [:index, :show]
resources "/performances", PerformanceController, only: [:index, :show]
+ resources "/visitors", VisitorController, only: [:new, :create]
+ get "/confirmation", VisitorController, :confirmation
end
scope "/admin", RunosaariWeb, as: :admin do
@@ -30,6 +32,7 @@ defmodule RunosaariWeb.Router do
get "/performances", PerformanceController, :admin
resources "/performers", PerformerController, except: [:index, :show]
resources "/performances", PerformanceController, except: [:index, :show]
+ resources "/visitors", VisitorController, except: [:new, :create]
end
# Other scopes may use custom stacks.
diff --git a/lib/runosaari_web/templates/layout/app.html.eex b/lib/runosaari_web/templates/layout/app.html.eex
index 4ab85fe..ecf6997 100644
--- a/lib/runosaari_web/templates/layout/app.html.eex
+++ b/lib/runosaari_web/templates/layout/app.html.eex
@@ -20,7 +20,7 @@
<%= link "Esiintyjät", to: Routes.performer_path(@conn, :index) %>
<%= link "Info", to: Routes.page_path(@conn, :info) %>
<%= link "Covid-19", to: Routes.page_path(@conn, :covid19) %>
- <%= link "Ilmoittautuminen", to: Routes.admin_performer_path(@conn, :new) %>
+ <%= link "Ilmoittautuminen", to: Routes.visitor_path(@conn, :new) %>
Runosaari 2021
@@ -31,7 +31,7 @@
<%= link "Esiintyjät", to: "#{Routes.performer_path(@conn, :index)}#performers-start" %>
<%= link "Info", to: "#{Routes.page_path(@conn, :info)}#contact-start" %>
<%= link "Covid-19", to: "#{Routes.page_path(@conn, :covid19)}#covid-start" %>
- <%= link "Ilmoittautuminen", to: "#{Routes.admin_performer_path(@conn, :new)}#registration-start" %>
+ <%= link "Ilmoittautuminen", to: "#{Routes.visitor_path(@conn, :new)}#registration-start" %>
diff --git a/lib/runosaari_web/templates/performer/new.html.eex b/lib/runosaari_web/templates/performer/new.html.eex
index b1642df..0f49bbd 100644
--- a/lib/runosaari_web/templates/performer/new.html.eex
+++ b/lib/runosaari_web/templates/performer/new.html.eex
@@ -1,5 +1,5 @@
- Ilmoittaudu
+ Ilmoittaudu
<%= render "form.html", Map.put(assigns, :action, Routes.admin_performer_path(@conn, :create)) %>
diff --git a/lib/runosaari_web/templates/visitor/confirmation.html.eex b/lib/runosaari_web/templates/visitor/confirmation.html.eex
new file mode 100644
index 0000000..95fd04b
--- /dev/null
+++ b/lib/runosaari_web/templates/visitor/confirmation.html.eex
@@ -0,0 +1,5 @@
+
+ Ilmoittautumisesi on rekisteröity.
+ Tervetuloa mukaan!
+ Tapahtuman järjestäjät ovat teihin yhteydessä sähköpostilla tarpeen mukaan.
+
diff --git a/lib/runosaari_web/templates/visitor/form.html.eex b/lib/runosaari_web/templates/visitor/form.html.eex
index 962cdf1..9a15edb 100644
--- a/lib/runosaari_web/templates/visitor/form.html.eex
+++ b/lib/runosaari_web/templates/visitor/form.html.eex
@@ -1,47 +1,55 @@
-<%= form_for @changeset, @action, fn f -> %>
+<%= form_for @changeset, @action, fn form -> %>
<%= if @changeset.action do %>
-
Oops, something went wrong! Please check the errors below.
+
Jokin kentistä on tyhjä.
<% end %>
- <%= label f, :fname %>
- <%= text_input f, :fname %>
- <%= error_tag f, :fname %>
+ <%= label form, :fname, "Etunimi" %>
+ <%= text_input form, :fname %>
+ <%= error_tag form, :fname %>
- <%= label f, :lname %>
- <%= text_input f, :lname %>
- <%= error_tag f, :lname %>
+ <%= label form, :lname, "Sukunimi" %>
+ <%= text_input form, :lname %>
+ <%= error_tag form, :lname %>
- <%= label f, :email %>
- <%= text_input f, :email %>
- <%= error_tag f, :email %>
+ <%= label form, :email, "Sähköposti" %>
+ <%= email_input form, :email %>
+ <%= error_tag form, :email %>
- <%= label f, :tel %>
- <%= text_input f, :tel %>
- <%= error_tag f, :tel %>
+ <%= label form, :tel, "Puhelinumero" %>
+ <%= text_input form, :tel %>
+ <%= error_tag form, :tel %>
- <%= label f, :date1 %>
- <%= checkbox f, :date1 %>
- <%= error_tag f, :date1 %>
+ Ilmoita alustava kiinnostuksesi tässä
- <%= label f, :date2 %>
- <%= checkbox f, :date2 %>
- <%= error_tag f, :date2 %>
-
- <%= label f, :date3 %>
- <%= checkbox f, :date3 %>
- <%= error_tag f, :date3 %>
-
- <%= label f, :bus %>
- <%= checkbox f, :bus %>
- <%= error_tag f, :bus %>
-
- <%= label f, :accom %>
- <%= checkbox f, :accom %>
- <%= error_tag f, :accom %>
+
+ <%= checkbox form, :date1 %>
+ <%= label form, :date1, "Torstai 22.7" %>
+ <%= error_tag form, :date1 %>
+
+
+ <%= checkbox form, :date2 %>
+ <%= label form, :date2, "Perjantai 23.7." %>
+ <%= error_tag form, :date2 %>
+
+
+ <%= checkbox form, :date3 %>
+ <%= label form, :date3, "Lauantai 24.7." %>
+ <%= error_tag form, :date3 %>
+
+
+ <%= checkbox form, :bus %>
+ <%= label form, :bus, "Olen kiinnostunut bussikuljetuksesta" %>
+ <%= error_tag form, :bus %>
+
+
+ <%= checkbox form, :accom %>
+ <%= label form, :accom, "Olen kiinnostunut majoituksesta" %>
+ <%= error_tag form, :accom %>
+
- <%= submit "Save" %>
+ <%= submit "Lähetä" %>
<% end %>
diff --git a/lib/runosaari_web/templates/visitor/new.html.eex b/lib/runosaari_web/templates/visitor/new.html.eex
index 70ab951..68e8003 100644
--- a/lib/runosaari_web/templates/visitor/new.html.eex
+++ b/lib/runosaari_web/templates/visitor/new.html.eex
@@ -1,5 +1,5 @@
-New Visitor
+
+ Ilmoittaudu vierailijaksi
-<%= render "form.html", Map.put(assigns, :action, Routes.visitor_path(@conn, :create)) %>
-
-<%= link "Back", to: Routes.visitor_path(@conn, :index) %>
+ <%= render "form.html", Map.put(assigns, :action, Routes.visitor_path(@conn, :create)) %>
+
diff --git a/test/runosaari_web/controllers/visitor_controller_test.exs b/test/runosaari_web/controllers/visitor_controller_test.exs
index ed61fe3..934c9b8 100644
--- a/test/runosaari_web/controllers/visitor_controller_test.exs
+++ b/test/runosaari_web/controllers/visitor_controller_test.exs
@@ -3,9 +3,39 @@ defmodule RunosaariWeb.VisitorControllerTest do
alias Runosaari.Registration
- @create_attrs %{accom: true, bus: true, date1: true, date2: true, date3: true, email: "some email", fname: "some fname", lname: "some lname", tel: "some tel"}
- @update_attrs %{accom: false, bus: false, date1: false, date2: false, date3: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", tel: "some updated tel"}
- @invalid_attrs %{accom: nil, bus: nil, date1: nil, date2: nil, date3: nil, email: nil, fname: nil, lname: nil, tel: nil}
+ @create_attrs %{
+ accom: true,
+ bus: true,
+ date1: true,
+ date2: true,
+ date3: true,
+ email: "some email",
+ fname: "some fname",
+ lname: "some lname",
+ tel: "some tel"
+ }
+ @update_attrs %{
+ accom: false,
+ bus: false,
+ date1: false,
+ date2: false,
+ date3: false,
+ email: "some updated email",
+ fname: "some updated fname",
+ lname: "some updated lname",
+ tel: "some updated tel"
+ }
+ @invalid_attrs %{
+ accom: nil,
+ bus: nil,
+ date1: nil,
+ date2: nil,
+ date3: nil,
+ email: nil,
+ fname: nil,
+ lname: nil,
+ tel: nil
+ }
def fixture(:visitor) do
{:ok, visitor} = Registration.create_visitor(@create_attrs)
@@ -57,6 +87,7 @@ defmodule RunosaariWeb.VisitorControllerTest do
test "redirects when data is valid", %{conn: conn, visitor: visitor} do
conn = put(conn, Routes.visitor_path(conn, :update, visitor), visitor: @update_attrs)
+
assert redirected_to(conn) == Routes.visitor_path(conn, :show, visitor)
conn = get(conn, Routes.visitor_path(conn, :show, visitor))
@@ -65,6 +96,7 @@ defmodule RunosaariWeb.VisitorControllerTest do
test "renders errors when data is invalid", %{conn: conn, visitor: visitor} do
conn = put(conn, Routes.visitor_path(conn, :update, visitor), visitor: @invalid_attrs)
+
assert html_response(conn, 200) =~ "Edit Visitor"
end
end
@@ -75,6 +107,7 @@ defmodule RunosaariWeb.VisitorControllerTest do
test "deletes chosen visitor", %{conn: conn, visitor: visitor} do
conn = delete(conn, Routes.visitor_path(conn, :delete, visitor))
assert redirected_to(conn) == Routes.visitor_path(conn, :index)
+
assert_error_sent 404, fn ->
get(conn, Routes.visitor_path(conn, :show, visitor))
end