summaryrefslogtreecommitdiff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2024-12-29 15:14:43 +0100
committerMarius Peter <marius.peter@tutanota.com>2024-12-29 15:14:43 +0100
commitbe2a93525069de2dfa3c23b0c23e7a9f7ad4c03d (patch)
treeb5493e9d35d024ce7be072ec2168b4a98ba0e63f /app/controllers/admin
First commit.
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/dashboard_controller.rb13
-rw-r--r--app/controllers/admin/scores_controller.rb14
2 files changed, 27 insertions, 0 deletions
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
new file mode 100644
index 0000000..695c2ca
--- /dev/null
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -0,0 +1,13 @@
+class Admin::DashboardController < ApplicationController
+ def index
+ @tartiflettes = Tartiflette.includes(:scores)
+ end
+
+ private
+
+ def require_admin
+ unless logged_in? && current_user.admin?
+ redirect_to root_path, alert: "Access denied."
+ end
+ end
+end
diff --git a/app/controllers/admin/scores_controller.rb b/app/controllers/admin/scores_controller.rb
new file mode 100644
index 0000000..b4755e9
--- /dev/null
+++ b/app/controllers/admin/scores_controller.rb
@@ -0,0 +1,14 @@
+class Admin::ScoresController < ApplicationController
+ def export
+ csv_data = TartifletteScoreExportService.generate_csv
+ send_data csv_data, filename: "scores-#{Date.today}.csv"
+ end
+
+ private
+
+ def require_admin
+ unless logged_in? && current_user.admin?
+ redirect_to root_path, alert: "Access denied."
+ end
+ end
+end
Copyright 2019--2025 Marius PETER