Browse Source
* [CLDC-1619] Add cookies page and logic to manage them * Update app/views/cookies/show.html.erb Co-authored-by: James Rose <james@jbpr.net> Co-authored-by: James Rose <james@jbpr.net>pull/972/head
Jack S
2 years ago
committed by
GitHub
5 changed files with 128 additions and 0 deletions
@ -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 |
@ -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 |
@ -0,0 +1,81 @@ |
|||||||
|
<% content_for :title, "Cookies" %> |
||||||
|
|
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<h1 class="govuk-heading-xl">Cookies</h1> |
||||||
|
<p>Cookies are small files saved on your phone, tablet or computer when you visit a website.</p> |
||||||
|
<p>We use cookies to make the Submit social housing lettings and sales data (CORE) (the service) work and collect information about how you use our service.</p> |
||||||
|
|
||||||
|
<h2 class="govuk-heading-m">Essential cookies</h2> |
||||||
|
<p>Essential cookies keep your information secure while you use the service. We do not need to ask permission to use them. </p> |
||||||
|
|
||||||
|
<table class="govuk-table"> |
||||||
|
<caption class="govuk-visually-hidden">Essential cookies</caption> |
||||||
|
<thead class="govuk-table__head"> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<th class="govuk-table__header">Name</th> |
||||||
|
<th class="govuk-table__header">Purpose</th> |
||||||
|
<th class="govuk-table__header">Expires</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody class="govuk-table__body"> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<td class="govuk-table__cell">_data_collector_session</td> |
||||||
|
<td class="govuk-table__cell" width="50%">Used to keep you signed in</td> |
||||||
|
<td class="govuk-table__cell">2 weeks</td> |
||||||
|
</tr> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<td class="govuk-table__cell">accept_analytics_cookies</td> |
||||||
|
<td class="govuk-table__cell" width="50%">Saves your cookie consent settings</td> |
||||||
|
<td class="govuk-table__cell">1 year</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<h2 class="govuk-heading-m">Analytics cookies (optional)</h2> |
||||||
|
<p>With your permission, we use Google Analytics to collect data about how you use the service. This information helps us to improve our service.</p> |
||||||
|
<p>Google is not allowed to use or share our analytics data with anyone.</p> |
||||||
|
<p>Google Analytics stores anonymised information about:</p> |
||||||
|
|
||||||
|
<ul class="govuk-list govuk-list--bullet"> |
||||||
|
<li>how you got to the service</li> |
||||||
|
<li>the pages you visit on the service and how long you spend on them</li> |
||||||
|
<li>any errors you see while using the service</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<table class="govuk-table"> |
||||||
|
<caption class="govuk-visually-hidden">Google Analytics cookies</caption> |
||||||
|
<thead class="govuk-table__head"> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<th class="govuk-table__header">Name</th> |
||||||
|
<th class="govuk-table__header">Purpose</th> |
||||||
|
<th class="govuk-table__header">Expires</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody class="govuk-table__body"> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<td class="govuk-table__cell">_ga</td> |
||||||
|
<td class="govuk-table__cell" width="50%">Checks if you’ve visited the service before. This helps us count how many people visit our site.</td> |
||||||
|
<td class="govuk-table__cell">2 years</td> |
||||||
|
</tr> |
||||||
|
<tr class="govuk-table__row"> |
||||||
|
<td class="govuk-table__cell">_gid</td> |
||||||
|
<td class="govuk-table__cell" width="50%">Checks if you’ve visited the service before. This helps us count how many people visit our site.</td> |
||||||
|
<td class="govuk-table__cell">24 hours</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<%= form_for @cookies_form, url: cookies_path, method: :put do |f| %> |
||||||
|
<%= f.govuk_collection_radio_buttons( |
||||||
|
:accept_analytics_cookies, |
||||||
|
@cookies_form.consent_options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
inline: true, |
||||||
|
legend: { text: "Do you want to accept analytics cookies?" }, |
||||||
|
) %> |
||||||
|
<%= f.govuk_submit "Save cookie settings" %> |
||||||
|
<% end %> |
||||||
|
</div> |
||||||
|
</div> |
Loading…
Reference in new issue