From cebe145c32ee33003f65fd4fa4faf63d08563c47 Mon Sep 17 00:00:00 2001 From: codevictory Date: Thu, 22 Apr 2021 21:00:55 +0300 Subject: [PATCH] Admin pages. --- .../controllers/location_controller.ex | 5 +++ .../controllers/performance_controller.ex | 5 +++ .../controllers/performer_controller.ex | 5 +++ lib/runosaari_web/router.ex | 3 ++ .../templates/location/admin.html.eex | 34 ++++++++++++++++++ .../templates/location/index.html.eex | 8 +---- .../templates/performance/admin.html.eex | 30 ++++++++++++++++ .../templates/performance/index.html.eex | 8 +---- .../templates/performer/admin.html.eex | 36 +++++++++++++++++++ .../templates/performer/index.html.eex | 9 +---- 10 files changed, 121 insertions(+), 22 deletions(-) create mode 100644 lib/runosaari_web/templates/location/admin.html.eex create mode 100644 lib/runosaari_web/templates/performance/admin.html.eex create mode 100644 lib/runosaari_web/templates/performer/admin.html.eex diff --git a/lib/runosaari_web/controllers/location_controller.ex b/lib/runosaari_web/controllers/location_controller.ex index bbdcba9..21e95c7 100644 --- a/lib/runosaari_web/controllers/location_controller.ex +++ b/lib/runosaari_web/controllers/location_controller.ex @@ -9,6 +9,11 @@ defmodule RunosaariWeb.LocationController do render(conn, "index.html", locations: locations) end + def admin(conn, _params) do + locations = Area.list_locations() + render(conn, "admin.html", locations: locations) + end + def new(conn, _params) do changeset = Area.change_location(%Location{}) render(conn, "new.html", changeset: changeset) diff --git a/lib/runosaari_web/controllers/performance_controller.ex b/lib/runosaari_web/controllers/performance_controller.ex index e4bc80d..bed2d6b 100644 --- a/lib/runosaari_web/controllers/performance_controller.ex +++ b/lib/runosaari_web/controllers/performance_controller.ex @@ -9,6 +9,11 @@ defmodule RunosaariWeb.PerformanceController do render(conn, "index.html", performances: performances) end + def admin(conn, _params) do + performances = Schedule.list_performances() + render(conn, "admin.html", performances: performances) + end + def new(conn, _params) do changeset = Schedule.change_performance(%Performance{}) render(conn, "new.html", changeset: changeset) diff --git a/lib/runosaari_web/controllers/performer_controller.ex b/lib/runosaari_web/controllers/performer_controller.ex index e314185..5671398 100644 --- a/lib/runosaari_web/controllers/performer_controller.ex +++ b/lib/runosaari_web/controllers/performer_controller.ex @@ -9,6 +9,11 @@ defmodule RunosaariWeb.PerformerController do render(conn, "index.html", performers: performers) end + def admin(conn, _params) do + performers = Registration.list_performers() + render(conn, "admin.html", performers: performers) + end + def new(conn, _params) do changeset = Registration.change_performer(%Performer{}) render(conn, "new.html", changeset: changeset) diff --git a/lib/runosaari_web/router.ex b/lib/runosaari_web/router.ex index 6e586d2..c0b6637 100644 --- a/lib/runosaari_web/router.ex +++ b/lib/runosaari_web/router.ex @@ -25,6 +25,9 @@ defmodule RunosaariWeb.Router do scope "/admin", RunosaariWeb, as: :admin do pipe_through :browser + get "/performers", PerformerController, :admin + get "/performers", PerformanceController, :admin + get "/performers", LocationController, :admin resources "/performers", PerformerController, except: [:index, :show] resources "/performances", PerformanceController, except: [:index, :show] resources "/locations", LocationController, except: [:index, :show] diff --git a/lib/runosaari_web/templates/location/admin.html.eex b/lib/runosaari_web/templates/location/admin.html.eex new file mode 100644 index 0000000..fc4e5d2 --- /dev/null +++ b/lib/runosaari_web/templates/location/admin.html.eex @@ -0,0 +1,34 @@ +

Tapahtumapaikat - HALLINTA

+ + + + + + + + + + + + + + +<%= for location <- @locations do %> + + + + + + + + + +<% end %> + +
NameAddressReserved seatsMax seatsDescription
<%= location.name %><%= location.address %><%= location.reserved_seats %><%= location.max_seats %><%= location.description %> + <%= link "Show", to: Routes.location_path(@conn, :show, location) %> + <%= link "Edit", to: Routes.admin_location_path(@conn, :edit, location) %> + <%= link "Delete", to: Routes.admin_location_path(@conn, :delete, location), method: :delete, data: [confirm: "Are you sure?"] %> +
+ +<%= link "New Location", to: Routes.admin_location_path(@conn, :new) %> diff --git a/lib/runosaari_web/templates/location/index.html.eex b/lib/runosaari_web/templates/location/index.html.eex index eb35e96..1d7d363 100644 --- a/lib/runosaari_web/templates/location/index.html.eex +++ b/lib/runosaari_web/templates/location/index.html.eex @@ -20,15 +20,9 @@ <%= location.reserved_seats %> <%= location.max_seats %> <%= location.description %> - - - <%= link "Show", to: Routes.location_path(@conn, :show, location) %> - <%= link "Edit", to: Routes.admin_location_path(@conn, :edit, location) %> - <%= link "Delete", to: Routes.admin_location_path(@conn, :delete, location), method: :delete, data: [confirm: "Are you sure?"] %> - <% end %> -<%= link "New Location", to: Routes.admin_location_path(@conn, :new) %> +<%= link "Hallinta", to: Routes.admin_location_path(@conn, :admin) %> diff --git a/lib/runosaari_web/templates/performance/admin.html.eex b/lib/runosaari_web/templates/performance/admin.html.eex new file mode 100644 index 0000000..eabc5d4 --- /dev/null +++ b/lib/runosaari_web/templates/performance/admin.html.eex @@ -0,0 +1,30 @@ +

Ohjelma - HALLINTA

+ + + + + + + + + + + + +<%= for performance <- @performances do %> + + + + + + + +<% end %> + +
TimeDescriptionNotes
<%= performance.time %><%= performance.description %><%= performance.notes %> + <%= link "Show", to: Routes.performance_path(@conn, :show, performance) %> + <%= link "Edit", to: Routes.admin_performance_path(@conn, :edit, performance) %> + <%= link "Delete", to: Routes.admin_performance_path(@conn, :delete, performance), method: :delete, data: [confirm: "Are you sure?"] %> +
+ +<%= link "New Performance", to: Routes.admin_performance_path(@conn, :new) %> diff --git a/lib/runosaari_web/templates/performance/index.html.eex b/lib/runosaari_web/templates/performance/index.html.eex index 026af55..bcf6ef8 100644 --- a/lib/runosaari_web/templates/performance/index.html.eex +++ b/lib/runosaari_web/templates/performance/index.html.eex @@ -16,15 +16,9 @@ <%= performance.time %> <%= performance.description %> <%= performance.notes %> - - - <%= link "Show", to: Routes.performance_path(@conn, :show, performance) %> - <%= link "Edit", to: Routes.admin_performance_path(@conn, :edit, performance) %> - <%= link "Delete", to: Routes.admin_performance_path(@conn, :delete, performance), method: :delete, data: [confirm: "Are you sure?"] %> - <% end %> -<%= link "New Performance", to: Routes.admin_performance_path(@conn, :new) %> +<%= link "Hallinta", to: Routes.admin_performance_path(@conn, :admin) %> diff --git a/lib/runosaari_web/templates/performer/admin.html.eex b/lib/runosaari_web/templates/performer/admin.html.eex new file mode 100644 index 0000000..061a942 --- /dev/null +++ b/lib/runosaari_web/templates/performer/admin.html.eex @@ -0,0 +1,36 @@ +

Esiintyjät - HALLINTA

+ + + + + + + + + + + + + + + +<%= for performer <- @performers do %> + + + + + + + + + + +<% end %> + +
FnameLnameEmailTelConfirmedNotes
<%= performer.fname %><%= performer.lname %><%= performer.email %><%= performer.tel %><%= performer.confirmed %><%= performer.notes %> + <%= link "Show", to: Routes.performer_path(@conn, :show, performer) %> + <%= link "Edit", to: Routes.admin_performer_path(@conn, :edit, performer) %> + <%= link "Delete", to: Routes.admin_performer_path(@conn, :delete, performer), method: :delete, data: [confirm: "Are you sure?"] %> +
+ +<%= link "New Performance", to: Routes.admin_performance_path(@conn, :new) %> diff --git a/lib/runosaari_web/templates/performer/index.html.eex b/lib/runosaari_web/templates/performer/index.html.eex index 39f6da1..9c0876e 100644 --- a/lib/runosaari_web/templates/performer/index.html.eex +++ b/lib/runosaari_web/templates/performer/index.html.eex @@ -22,15 +22,8 @@ <%= performer.tel %> <%= performer.confirmed %> <%= performer.notes %> - - - <%= link "Show", to: Routes.performer_path(@conn, :show, performer) %> - <%= link "Edit", to: Routes.admin_performer_path(@conn, :edit, performer) %> - <%= link "Delete", to: Routes.admin_performer_path(@conn, :delete, performer), method: :delete, data: [confirm: "Are you sure?"] %> - <% end %> - -<%= link "New Performance", to: Routes.admin_performance_path(@conn, :new) %> +<%= link "Hallinta", to: Routes.admin_performer_path(@conn, :admin) %>