From 87d51e88562faf61eb81a3a3833a2799813d86a0 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 17:31:35 -0300 Subject: [PATCH 1/5] feat: pedir consentimiento #12795 --- app/views/bootstrap/_custom_checkbox.haml | 6 ++++++ app/views/devise/registrations/new.haml | 18 +++++++++++++++++- config/locales/devise.views.en.yml | 19 +++++++++++++++++++ config/locales/devise.views.es.yml | 18 ++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) 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..0c3ff3a6 --- /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 diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index e6bda964..75015831 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -4,7 +4,7 @@ = render 'devise/shared/error_messages', resource: resource .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') @@ -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") + - 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 + - if href.present? + = link_to help_content, href, target: '_blank', rel: 'noopener' + - else + = help_content + .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 793f3a0a..3dd666b1 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: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 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 b745fc5f..c955373f 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: "Hemos enviado un mensaje con un enlace de confirmación a tu correo electrónico. Por favor, abrí el enlace para terminar de activar tu cuenta." 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 8f0f260a4f9bd345eddcf66ab079da054d9d2a00 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 18:18:53 -0300 Subject: [PATCH 2/5] feat: almacenar los campos --- app/models/concerns/usuarie/consent.rb | 26 +++++++++++++++++++ app/models/usuarie.rb | 2 ++ app/views/devise/registrations/new.haml | 2 +- .../20230328200129_add_consent_to_usuaries.rb | 12 +++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/models/concerns/usuarie/consent.rb create mode 100644 db/migrate/20230328200129_add_consent_to_usuaries.rb diff --git a/app/models/concerns/usuarie/consent.rb b/app/models/concerns/usuarie/consent.rb new file mode 100644 index 00000000..14e67fbc --- /dev/null +++ b/app/models/concerns/usuarie/consent.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class Usuarie + # Gestiona los campos de consentimiento + module Consent + extend ActiveSupport::Concern + + included do + CONSENT_FIELDS = %i[privacy_policy_accepted terms_of_service_accepted code_of_conduct_accepted available_for_feedback_accepted] + + CONSENT_FIELDS.each do |field| + attribute field, :boolean + end + + before_save :update_consent_fields! + + private + + def update_consent_fields! + CONSENT_FIELDS.each do |field| + send(:"#{field}_at=", Time.now) if send(field).present? + end + end + end + end +end diff --git a/app/models/usuarie.rb b/app/models/usuarie.rb index 7b83ee75..9b9fd4e6 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 75015831..04e81917 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 492d238f579b02f6a0ffdbe78e71f4b00c554ae8 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 28 Mar 2023 18:33:19 -0300 Subject: [PATCH 3/5] =?UTF-8?q?BREAKING=20CHANGE:=20eliminar=20campo=20que?= =?UTF-8?q?=20no=20se=20us=C3=B3=20nunca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...remove_acepta_politicas_de_privacidad_from_usuaries.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20230328213242_remove_acepta_politicas_de_privacidad_from_usuaries.rb diff --git a/db/migrate/20230328213242_remove_acepta_politicas_de_privacidad_from_usuaries.rb b/db/migrate/20230328213242_remove_acepta_politicas_de_privacidad_from_usuaries.rb new file mode 100644 index 00000000..7ca562bf --- /dev/null +++ b/db/migrate/20230328213242_remove_acepta_politicas_de_privacidad_from_usuaries.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Elimina un campo que nunca se usó +class RemoveAceptaPoliticasDePrivacidadFromUsuaries < ActiveRecord::Migration[6.1] + def change + remove_column :usuaries, :acepta_politicas_de_privacidad, :boolean, default: false + end +end From c66d1f0f087310085da99f8e76fb7389d783cbdc Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:50:45 -0300 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20mejorar=20la=20redacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/devise.views.en.yml | 6 +++--- config/locales/devise.views.es.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/devise.views.en.yml b/config/locales/devise.views.en.yml index 3dd666b1..a524cf7c 100644 --- a/config/locales/devise.views.en.yml +++ b/config/locales/devise.views.en.yml @@ -105,17 +105,17 @@ en: 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" + label: "I understand and accept the 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" + label: "My sites won't promote hate speech" 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" + label: "I want a more inclusive Internet" help: "Read codes for sharing" href: "https://sutty.nl/en/code-of-conduct/" required: true diff --git a/config/locales/devise.views.es.yml b/config/locales/devise.views.es.yml index c955373f..4575c628 100644 --- a/config/locales/devise.views.es.yml +++ b/config/locales/devise.views.es.yml @@ -105,17 +105,17 @@ es: 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" + label: "Comprendo y acepto la política de privacidad" 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" + label: "Mis sitios no promueven el discurso de odio" 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" + label: "Quiero una Internet más inclusiva" help: "Leer códigos para compartir" href: "https://sutty.nl/codigo-de-convivencia/" required: "true" From 414fd7348d7b5b3d9801ee7f8068c193b12d3df8 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 29 Mar 2023 15:51:10 -0300 Subject: [PATCH 5/5] fix: activarlo --- app/views/devise/registrations/new.haml | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/views/devise/registrations/new.haml b/app/views/devise/registrations/new.haml index 04e81917..26fc8e18 100644 --- a/app/views/devise/registrations/new.haml +++ b/app/views/devise/registrations/new.haml @@ -40,20 +40,19 @@ aria: { describedby: 'minimum-password-length' }, placeholder: t("#{password}_confirmation") - - if params[:consent] - .form-group - - Usuarie::CONSENT_FIELDS.each do |field| - - required = t(".#{field}.required", default: '').present? - - 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 - - if href.present? - = link_to help_content, href, target: '_blank', rel: 'noopener' - - else - = help_content + .form-group + - Usuarie::CONSENT_FIELDS.each do |field| + - required = t(".#{field}.required", default: '').present? + - 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 + - if href.present? + = link_to help_content, href, target: '_blank', rel: 'noopener' + - else + = help_content .actions = f.submit t('.sign_up'),