From 81392c8cf5ff9116df4cb39ff22573f03b89f1ec Mon Sep 17 00:00:00 2001 From: kunal-singh-tamu Date: Sat, 19 Oct 2024 16:34:59 -0500 Subject: [PATCH] Added Admin Dashboard button to provide survey response access to admins through home page. --- README.md | 2 -- .../survey_responses_controller.rb | 1 + rails_root/app/views/admins/index.html.erb | 28 +++++++++++-------- rails_root/app/views/layouts/_header.html.erb | 4 +++ rails_root/config/routes.rb | 4 ++- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 26df7df..0b02bd0 100644 --- a/README.md +++ b/README.md @@ -154,5 +154,3 @@ heroku run rails db:seed * [Legacy Code](https://github.com/tamu-edu-students/csce606-ELRC-Synergistic-Leadership-Theory) -# demo check commit -# second demo push diff --git a/rails_root/app/controllers/survey_responses_controller.rb b/rails_root/app/controllers/survey_responses_controller.rb index 504bf5b..4b1b1ed 100644 --- a/rails_root/app/controllers/survey_responses_controller.rb +++ b/rails_root/app/controllers/survey_responses_controller.rb @@ -25,6 +25,7 @@ def index def show return return_to_root 'You are not logged in.' if current_user_id.nil? return return_to_root 'You cannot view this result.' if current_user_id != @survey_response.profile.user_id + flash.keep(:warning) end diff --git a/rails_root/app/views/admins/index.html.erb b/rails_root/app/views/admins/index.html.erb index d2db529..a332500 100644 --- a/rails_root/app/views/admins/index.html.erb +++ b/rails_root/app/views/admins/index.html.erb @@ -8,22 +8,26 @@
- - - - - - + + + + + + + <% if @survey_responses.present? %> <% @survey_responses.each do |response| %> - - - - - - + + + + + + + <% end %> <% end %> diff --git a/rails_root/app/views/layouts/_header.html.erb b/rails_root/app/views/layouts/_header.html.erb index 763a97a..8a1b94e 100644 --- a/rails_root/app/views/layouts/_header.html.erb +++ b/rails_root/app/views/layouts/_header.html.erb @@ -23,6 +23,10 @@ + + diff --git a/rails_root/config/routes.rb b/rails_root/config/routes.rb index 32d6ccb..bac42dc 100644 --- a/rails_root/config/routes.rb +++ b/rails_root/config/routes.rb @@ -8,7 +8,9 @@ get 'home/index' get 'about', to: 'about#index' - get '/admin', to: 'admins#index' + get '/admin', to: 'admins#index', as: 'admin_dashboard' + #get 'survey_responses/:id', to: 'survey_responses#show', as: 'survey_response' + # get 'survey', to: 'survey_responses#new', as: 'survey' # get 'survey/page/:page', to: 'survey_responses#survey', as: 'survey_page'
IDProfileShare CodeCreated At
IDProfileShare CodeCreated AtView Survey
<%= response.id %><%= response.profile.user_id %><%= response.share_code %><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %>
<%= response.id %><%= response.profile.user_id %><%= response.share_code %><%= response.created_at.strftime('%Y-%m-%d %H:%M:%S') %> + <%= link_to 'View Survey', survey_response_path(response) %> +