From fd109d79c33b4ebb708d4e6132847bb31251719b Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 17:31:35 -0300 Subject: [PATCH 1/6] feat: pedir consentimiento #12795 --- app/views/devise/registrations/new.haml | 16 ++++++++++++++++ config/locales/devise.views.en.yml | 19 +++++++++++++++++++ config/locales/devise.views.es.yml | 18 ++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 21676556..eab4a870 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -39,6 +39,22 @@ min: @minimum_password_length, aria: { describedby: 'minimum-password-length' }, placeholder: t("#{password}_confirmation") + + - if params[:consent] + .form-group + - %i[privacy_policy_accepted terms_of_service_accepted code_of_conduct_accepted available_for_feedback_accepted].each do |field| + - required = t(".#{field}.required", default: '').present? + - id = "usuarie_#{field}" + - name = "usuarie[#{field}]" + - content = t(".#{field}.label") + = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required do + - href = t(".#{field}.href", default: '') + - help = t(".#{field}.help") + - if href.present? + = link_to help, href, target: '_blank', rel: 'noopener' + - else + = help + .actions = f.submit t('.sign_up'), class: 'btn btn-lg btn-block' diff --git a/config/locales/devise.views.en.yml b/config/locales/devise.views.en.yml index fd041b33..53a3f16e 100644 --- a/config/locales/devise.views.en.yml +++ b/config/locales/devise.views.en.yml @@ -104,6 +104,25 @@ en: new: sign_up: Sign up help: We only ask for an e-mail address and a password. The password is safely stored, no one else besides you knows it! You'll also receive an e-mail to confirm your account. + privacy_policy_accepted: + label: "I know about Sutty's privacy policy" + help: "Read privacy policy" + href: "https://sutty.nl/en/privacy-policy/" + required: true + terms_of_service_accepted: + label: "My sites won't promote hate towards minorities" + help: "Read terms of service" + href: "https://sutty.nl/en/terms-of-service/" + required: true + code_of_conduct_accepted: + label: "My sites are inclusive spaces" + help: "Read codes for sharing" + href: "https://sutty.nl/en/code-of-conduct/" + required: true + available_for_feedback_accepted: + label: "I'm available to provide feedback" + help: "We may contact you occasionaly" + required: false signed_up: Welcome! You have signed up successfully. signed_up_but_inactive: You have signed up successfully. However, we could not sign you in because your account is not yet activated. signed_up_but_locked: You have signed up successfully. However, we could not sign you in because your account is locked. diff --git a/config/locales/devise.views.es.yml b/config/locales/devise.views.es.yml index 73166afc..6ad7628c 100644 --- a/config/locales/devise.views.es.yml +++ b/config/locales/devise.views.es.yml @@ -104,6 +104,24 @@ es: new: sign_up: Registrarme help: Para registrarte solo pedimos una dirección de correo y una contraseña. La contraseña se almacena de forma segura, ¡nadie más que vos la sabe! Recibirás un correo de confirmación de cuenta. + privacy_policy_accepted: + label: "Conozco la política de privacidad de Sutty" + help: "Leer política de privacidad" + href: "https://sutty.nl/politica-de-privacidad/" + required: "true" + terms_of_service_accepted: + label: "Mis sitios no promueven el odio a minorías" + help: "Leer términos de servicio" + href: "https://sutty.nl/terminos-de-servicio/" + required: "true" + code_of_conduct_accepted: + label: "Mis sitios son espacios inclusivos" + help: "Leer códigos para compartir" + href: "https://sutty.nl/codigo-de-convivencia/" + required: "true" + available_for_feedback_accepted: + label: "Estoy disponible para ofrecer retroalimentación" + help: "Te contactaremos ocasionalmente" signed_up: Bienvenide. Tu cuenta fue creada. signed_up_but_inactive: Tu cuenta ha sido creada correctamente. Sin embargo, no hemos podido iniciar la sesión porque tu cuenta aún no está activada. signed_up_but_locked: Tu cuenta ha sido creada correctamente. Sin embargo, no hemos podido iniciar la sesión porque que tu cuenta está bloqueada. From 75a92108f2da068d2fcc2805428814b3af8824f3 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 17:38:28 -0300 Subject: [PATCH 2/6] fixup! feat: pedir consentimiento #12795 --- app/views/bootstrap/_custom_checkbox.haml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/views/bootstrap/_custom_checkbox.haml diff --git a/app/views/bootstrap/_custom_checkbox.haml b/app/views/bootstrap/_custom_checkbox.haml new file mode 100644 index 00000000..339c05d2 --- /dev/null +++ b/app/views/bootstrap/_custom_checkbox.haml @@ -0,0 +1,6 @@ +- help_id = "#{id}-help" + +.custom-control.custom-checkbox + %input.custom-control-input{ id: id, type: 'checkbox', name: name, value: value, required: required } + %label.custom-control-label{ for: id, aria: { describedby: help_id } }= content + %small.form-text.text-muted{ id: help_id }= yield From 221bab97dcda938cb585456cb803aa95b78f8ff7 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 17:39:17 -0300 Subject: [PATCH 3/6] fixup! fixup! feat: pedir consentimiento #12795 --- app/views/devise/registrations/new.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index eab4a870..de8879da 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -47,7 +47,7 @@ - id = "usuarie_#{field}" - name = "usuarie[#{field}]" - content = t(".#{field}.label") - = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required do + = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: "1" do - href = t(".#{field}.href", default: '') - help = t(".#{field}.help") - if href.present? From 1444b57161550b1594591a60f337f8e4f0c33735 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 17:55:46 -0300 Subject: [PATCH 4/6] fixup! fixup! fixup! feat: pedir consentimiento #12795 --- app/views/devise/registrations/new.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index de8879da..896fe45c 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -2,7 +2,7 @@ - 'black-bg' .row.align-items-center.justify-content-center.full-height - .col-md-5.align-self-center + .col-md-6.align-self-center %h2= t('.sign_up') %p= t('.help') @@ -47,13 +47,13 @@ - id = "usuarie_#{field}" - name = "usuarie[#{field}]" - content = t(".#{field}.label") + - href = t(".#{field}.href", default: '') + - help_content = t(".#{field}.help") = render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: "1" do - - href = t(".#{field}.href", default: '') - - help = t(".#{field}.help") - if href.present? - = link_to help, href, target: '_blank', rel: 'noopener' + = link_to help_content, href, target: '_blank', rel: 'noopener' - else - = help + = help_content .actions = f.submit t('.sign_up'), From 05be2bb51b4e9600c1180755cbe140a6c6830104 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 18:18:53 -0300 Subject: [PATCH 5/6] feat: almacenar los campos --- app/controllers/application_controller.rb | 1 + app/models/usuarie.rb | 2 ++ app/views/devise/registrations/new.haml | 2 +- db/migrate/20230328200129_add_consent_to_usuaries.rb | 12 ++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230328200129_add_consent_to_usuaries.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e80c279d..b6c1a4a8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -84,6 +84,7 @@ class ApplicationController < ActionController::Base protected def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: Usuarie::CONSENT_FIELDS) devise_parameter_sanitizer.permit(:account_update, keys: %i[lang]) end diff --git a/app/models/usuarie.rb b/app/models/usuarie.rb index c87d82f9..83c89272 100644 --- a/app/models/usuarie.rb +++ b/app/models/usuarie.rb @@ -2,6 +2,8 @@ # Usuarie de la plataforma class Usuarie < ApplicationRecord + include Usuarie::Consent + devise :invitable, :database_authenticatable, :recoverable, :rememberable, :validatable, :confirmable, :lockable, :registerable diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 896fe45c..78fed394 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -42,7 +42,7 @@ - if params[:consent] .form-group - - %i[privacy_policy_accepted terms_of_service_accepted code_of_conduct_accepted available_for_feedback_accepted].each do |field| + - Usuarie::CONSENT_FIELDS.each do |field| - required = t(".#{field}.required", default: '').present? - id = "usuarie_#{field}" - name = "usuarie[#{field}]" diff --git a/db/migrate/20230328200129_add_consent_to_usuaries.rb b/db/migrate/20230328200129_add_consent_to_usuaries.rb new file mode 100644 index 00000000..1e85864d --- /dev/null +++ b/db/migrate/20230328200129_add_consent_to_usuaries.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Agrega consentimientos a les usuaries. No usamos un loop de +# Usuarie::CONSENT_FIELDS porque quizás agreguemos campos luego. +class AddConsentToUsuaries < ActiveRecord::Migration[6.1] + def change + add_column :usuaries, :privacy_policy_accepted_at, :datetime + add_column :usuaries, :terms_of_service_accepted_at, :datetime + add_column :usuaries, :code_of_conduct_accepted_at, :datetime + add_column :usuaries, :available_for_feedback_accepted_at, :datetime + end +end From 33859946c27ac17301543c25e381e341a1f620e0 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 18:19:19 -0300 Subject: [PATCH 6/6] fixup! fixup! fixup! fixup! feat: pedir consentimiento #12795 --- app/views/bootstrap/_custom_checkbox.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/bootstrap/_custom_checkbox.haml b/app/views/bootstrap/_custom_checkbox.haml index 339c05d2..0c3ff3a6 100644 --- a/app/views/bootstrap/_custom_checkbox.haml +++ b/app/views/bootstrap/_custom_checkbox.haml @@ -1,4 +1,4 @@ -- help_id = "#{id}-help" +- help_id = "#{id}_help" .custom-control.custom-checkbox %input.custom-control-input{ id: id, type: 'checkbox', name: name, value: value, required: required }