From bf4af439b7bc09ba591c3d9d01f396e66b07eecb Mon Sep 17 00:00:00 2001 From: James Mead Date: Wed, 9 Aug 2023 14:23:02 +0100 Subject: [PATCH] Hide user research recruitment banner permanently Trello: https://trello.com/c/yGMU3sR2 If the user clicks on "Find out more" then we assume that they've completed the Google Form and therefore we don't want to annoy them by continuing to show them the recruitment banner. To achieve this we set User#current_user.user_research_recruitment_banner_hidden to true before sending them off to the Google Form. --- app/controllers/root_controller.rb | 2 +- .../user_research_recruitment_controller.rb | 8 ++++- app/views/root/index.html.erb | 2 +- ...arch_recruitment_banner_hidden_to_users.rb | 5 +++ db/schema.rb | 3 +- ...er_research_recruitment_controller_test.rb | 35 ++++++++++++++---- .../user_research_recruitment_banner_test.rb | 36 ++++++++++++++++++- 7 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20230804094159_add_user_research_recruitment_banner_hidden_to_users.rb diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index d0d9ecab4..297c303f8 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -18,7 +18,7 @@ def signin_required private def show_user_research_recruitment_banner? - !cookies[:dismiss_user_research_recruitment_banner] + !cookies[:dismiss_user_research_recruitment_banner] && !current_user.user_research_recruitment_banner_hidden? end helper_method :show_user_research_recruitment_banner? end diff --git a/app/controllers/user_research_recruitment_controller.rb b/app/controllers/user_research_recruitment_controller.rb index 67abc19a7..a34ac90e2 100644 --- a/app/controllers/user_research_recruitment_controller.rb +++ b/app/controllers/user_research_recruitment_controller.rb @@ -1,9 +1,15 @@ class UserResearchRecruitmentController < ApplicationController + USER_RESEARCH_RECRUITMENT_FORM_URL = "https://docs.google.com/forms/d/1Bdu_GqOrSR4j6mbuzXkFTQg6FRktRMQc8Y-q879Mny8/viewform".freeze + before_action :authenticate_user! skip_after_action :verify_authorized def update - if params[:choice] == "dismiss-banner" + case params[:choice] + when "participate" + current_user.update!(user_research_recruitment_banner_hidden: true) + redirect_to USER_RESEARCH_RECRUITMENT_FORM_URL, allow_other_host: true + when "dismiss-banner" cookies[:dismiss_user_research_recruitment_banner] = true redirect_to root_path end diff --git a/app/views/root/index.html.erb b/app/views/root/index.html.erb index 89b09ab94..efeb971fd 100644 --- a/app/views/root/index.html.erb +++ b/app/views/root/index.html.erb @@ -9,7 +9,7 @@

We're holding research sessions to make Publishing work better.

<%= form_tag user_research_recruitment_update_path, method: :put do %>
-