5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 12:51:42 +00:00

Merge branch 'issue-12795' into 'rails'

feat: pedir consentimiento #12795

See merge request sutty/sutty!133
This commit is contained in:
fauno 2023-04-10 15:35:29 +00:00
commit 4fa3f45e3c
8 changed files with 107 additions and 1 deletions

View file

@ -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

View file

@ -2,6 +2,8 @@
# Usuarie de la plataforma
class Usuarie < ApplicationRecord
include Usuarie::Consent
devise :invitable, :database_authenticatable,
:recoverable, :rememberable, :validatable,
:confirmable, :lockable, :registerable

View file

@ -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

View file

@ -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,21 @@
min: @minimum_password_length,
aria: { describedby: 'minimum-password-length' },
placeholder: t("#{password}_confirmation")
.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'),
class: 'btn btn-lg btn-block'

View file

@ -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 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 speech"
help: "Read terms of service"
href: "https://sutty.nl/en/terms-of-service/"
required: true
code_of_conduct_accepted:
label: "I want a more inclusive Internet"
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.

View file

@ -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: "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 discurso de odio"
help: "Leer términos de servicio"
href: "https://sutty.nl/terminos-de-servicio/"
required: "true"
code_of_conduct_accepted:
label: "Quiero una Internet más inclusiva"
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.

View file

@ -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

View file

@ -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