diff --git a/app/controllers/cookies_controller.rb b/app/controllers/cookies_controller.rb new file mode 100644 index 000000000..4809d099e --- /dev/null +++ b/app/controllers/cookies_controller.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CookiesController < ApplicationController + before_action :set_cookie_form, only: :show + + def show; end + + def update + analytics_consent = params[:cookies_form][:analytics_consent] + if %w[on off].include?(analytics_consent) + cookies[:accept_analytics_cookies] = { value: analytics_consent, expires: 1.year.from_now } + end + + respond_to do |format| + format.html do + set_cookie_form + flash[:notice] = "You’ve set your cookie preferences." + + redirect_to cookies_path + end + end + end + +private + + def set_cookie_form + @cookies_form = CookiesForm.new(accept_analytics_cookies: cookies[:accept_analytics_cookies]) + end +end diff --git a/app/models/cookies_form.rb b/app/models/cookies_form.rb new file mode 100644 index 000000000..02618e4b5 --- /dev/null +++ b/app/models/cookies_form.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CookiesForm + include ActiveModel::Model + + attr_accessor :accept_analytics_cookies + + def consent_options + [ + OpenStruct.new(id: "on", name: "Yes"), + OpenStruct.new(id: "off", name: "No"), + ] + end +end diff --git a/app/views/cookies/show.html.erb b/app/views/cookies/show.html.erb new file mode 100644 index 000000000..8b954f884 --- /dev/null +++ b/app/views/cookies/show.html.erb @@ -0,0 +1,81 @@ +<% content_for :title, "Cookies" %> + +
Cookies are small files saved on your phone, tablet or computer when you visit a website.
+We use cookies to make the Manage training for early career teachers service (the service) work and collect information about how you use our service.
+ +Essential cookies keep your information secure while you use the service. We do not need to ask permission to use them.
+ +Name | +Purpose | +Expires | +
---|---|---|
_data_collector_session | +Used to keep you signed in | +2 weeks | +
accept_analytics_cookies | +Saves your cookie consent settings | +1 year | +
With your permission, we use Google Analytics to collect data about how you use the service. This information helps us to improve our service.
+Google is not allowed to use or share our analytics data with anyone.
+Google Analytics stores anonymised information about:
+ +Name | +Purpose | +Expires | +
---|---|---|
_ga | +Checks if you’ve visited the service before. This helps us count how many people visit our site. | +2 years | +
_gid | +Checks if you’ve visited the service before. This helps us count how many people visit our site. | +24 hours | +