From 9067df61b153730725e6a7a9ab759997ab6d83ad Mon Sep 17 00:00:00 2001 From: Tocho Tochev Date: Mon, 23 Sep 2024 10:04:27 +0300 Subject: [PATCH] Ask volunteers to agree to our ToS --- .../public/volunteers_controller.rb | 2 +- app/models/volunteer.rb | 3 +- .../management/volunteers/_form.html.slim | 1 + config/database.yml | 57 ++++++++++--------- config/database.yml.postgres | 9 ++- config/environments/development.rb | 2 +- config/locales/bg.yml | 2 + config/locales/en.yml | 2 + ...3061535_add_terms_accepted_to_volunteer.rb | 5 ++ docker-compose.yml | 6 ++ .../views/public/volunteers/_form.slim | 1 + 11 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 db/migrate/20240923061535_add_terms_accepted_to_volunteer.rb diff --git a/app/controllers/public/volunteers_controller.rb b/app/controllers/public/volunteers_controller.rb index 1fa2cdd..143de79 100644 --- a/app/controllers/public/volunteers_controller.rb +++ b/app/controllers/public/volunteers_controller.rb @@ -39,7 +39,7 @@ module Public params.require(:volunteer).permit( :name, :picture, :email, :phone, :tshirt_size, :tshirt_cut, :food_preferences, :previous_experience, :notes, :language, - :volunteer_team_id + :terms_accepted, :volunteer_team_id, ) end end diff --git a/app/models/volunteer.rb b/app/models/volunteer.rb index 5368e52..e1ccde8 100644 --- a/app/models/volunteer.rb +++ b/app/models/volunteer.rb @@ -12,6 +12,7 @@ class Volunteer < ActiveRecord::Base validates :email, format: {with: /\A[^@]+@[^@]+\z/}, presence: true, uniqueness: {scope: :conference_id} validates :phone, presence: true, format: {with: /\A[+\- \(\)0-9]+\z/} validates :volunteer_team, presence: true + validates :terms_accepted, acceptance: true validate :volunteer_teams_belong_to_conference phony_normalize :phone, default_country_code: "BG" @@ -24,7 +25,7 @@ class Volunteer < ActiveRecord::Base before_create :assign_unique_id before_create :assign_confirmation_token after_commit :send_email_confirmation_to_volunteer, on: [:create] - after_commit :send_email_to_organisers, on: [:create] # technically the email is not confirmed yet + after_commit :send_email_to_organisers, on: [:create] # technically the volunteer's email is not confirmed yet def send_notification_to_volunteer VolunteerMailer.volunteer_notification(self).deliver_later diff --git a/app/views/management/volunteers/_form.html.slim b/app/views/management/volunteers/_form.html.slim index 6186233..ff1d05d 100644 --- a/app/views/management/volunteers/_form.html.slim +++ b/app/views/management/volunteers/_form.html.slim @@ -20,5 +20,6 @@ = f.input :food_preferences, collection: Volunteer::FOOD_PREFERENCES, wrapper: :horizontal_radio_and_checkboxes, as: :radio_buttons, checked: (@volunteer.food_preferences.presence || :none) = f.input :previous_experience = f.input :notes + = f.input :terms_accepted .panel-footer.text-right = f.submit class: 'btn btn-primary' diff --git a/config/database.yml b/config/database.yml index 827bc92..0b5bbf1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,35 +1,40 @@ -# PostgreSQL. Versions 9.3 and up are supported. +# PostgreSQL. Versions 9.1 and up are supported. # # Install the pg driver: # gem install pg -# On macOS with Homebrew: +# On OS X with Homebrew: # gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: +# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg # Choose the win32 build. # Install PostgreSQL and put its /bin directory on your path. # # Configure Using Gemfile -# gem "pg" +# gem 'pg' # default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see Rails configuration guide - # https://guides.rubyonrails.org/configuring.html#database-pooling + # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default - database: clarion_development + database: clarion + username: clarion + password: not-a-real-db-password-tiliez4phei9oZoo1Shoyitee2zoon8O + host: 127.0.0.1 - # The specified database role being used to connect to PostgreSQL. - # To create additional roles in PostgreSQL see `$ createuser --help`. - # When left blank, PostgreSQL will use the default role. This is - # the same name as the operating system user running Rails. + # The specified database role being used to connect to postgres. + # To create additional roles in postgres see `$ createuser --help`. + # When left blank, postgres will use the default role. This is + # the same name as the operating system user that initialized the database. #username: clarion - # The password associated with the PostgreSQL role (username). + # The password associated with the postgres role (username). #password: # Connect on a TCP socket. Omitted by default since the client uses a @@ -54,32 +59,32 @@ development: # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - <<: *default - database: clarion_test + adapter: sqlite3 + pool: 5 + timeout: 5000 + database: db/test.sqlite3 -# As with config/credentials.yml, you never want to store sensitive information, +# As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # -# Instead, provide the password or a full connection URL as an environment -# variable when you boot the app. For example: +# Instead, provide the password as a unix environment variable when you boot +# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full rundown on how to provide these environment variables in a +# production deployment. +# +# On Heroku and other platform providers, you may have a full connection URL +# available as an environment variable. For example: # # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" # -# If the connection URL is provided in the special DATABASE_URL environment -# variable, Rails will automatically merge its configuration values on top of -# the values provided in this file. Alternatively, you can specify a connection -# URL environment variable explicitly: +# You can use this database configuration with: # # production: -# url: <%= ENV["MY_APP_DATABASE_URL"] %> -# -# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database -# for a full overview on how database connection configuration can be specified. +# url: <%= ENV['DATABASE_URL'] %> # production: <<: *default - host: <%= ENV.fetch("CLARION_DATABASE_HOST") { "host.containers.internal" } %> - database: clarion + database: clarion_production username: clarion - password: <%= ENV["CLARION_DATABASE_PASSWORD"] %> + password: <%= ENV['CLARION_DATABASE_PASSWORD'] %> diff --git a/config/database.yml.postgres b/config/database.yml.postgres index f57fc94..57380e6 100644 --- a/config/database.yml.postgres +++ b/config/database.yml.postgres @@ -24,6 +24,9 @@ default: &default development: <<: *default database: clarion_development + username: clarion + password: not-a-real-db-password-tiliez4phei9oZoo1Shoyitee2zoon8O + host: 127.0.0.1 # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. @@ -56,8 +59,10 @@ development: # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - <<: *default - database: clarion_test + adapter: sqlite3 + pool: 5 + timeout: 5000 + database: db/test.sqlite3 # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is diff --git a/config/environments/development.rb b/config/environments/development.rb index cd5c6d8..2d0a3f0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,7 +12,7 @@ Rails.application.configure do config.eager_load = false # Show full error reports. - config.consider_all_requests_local = true + config.consider_all_requests_local = false # Enable server timing config.server_timing = true diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 7d82de3..9842ed0 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -118,6 +118,7 @@ bg: food_preferences: Предпочитана храна previous_experience: Предишен опит notes: Бележки + terms_accepted: Съгласен съм екипът да се свързва с мен language: Език volunteer_team: Екип доброволци additional_volunteer_teams: Допълнителни екипи доброволци @@ -373,6 +374,7 @@ bg: phone: "Мобилният ви телефон, който ще бъде видим само за организаторите" picture: "Ваша снимка в jpeg, png или gif формат" volunteer_team: "Доброволческият екип, от които искате да бъдете част. Подробни описания на екипите можете да намерите тук. Ако желаете да участвате в повече от един екип, споменете това в полето бележка." + terms_accepted: "Съгласен съм екипът да се свързва с мен, както и с политиката за данни и общите условия." user: email: e-mail адресът ви. Ще бъде видим само от организаторите password: "Парола с дължина между 8 и 128 символа" diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f24b78..a9ea28a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -118,6 +118,7 @@ en: food_preferences: Food preference previous_experience: Previous experience notes: Notes + terms_accepted: I agree to be contacted by the team language: Language volunteer_team: Volunteer team additional_volunteer_teams: Additional volunteer teams @@ -373,6 +374,7 @@ en: phone: "Your mobile phone. It will be visible only to the organizers" picture: "A picture of you in jpeg, png or gif format" volunteer_team: "The volunteer team you'd like to be a part of. You can find a description of each team here. Leave a note in the Notes field if you wish to be a part of any additional teams." + terms_accepted: "I agree to be contacted by the team, and with the terms of service and the privacy policy." user: email: Your e-mail address. Will be visible to the organizers only. password: "Password with length between 8 and 128 symbols" diff --git a/db/migrate/20240923061535_add_terms_accepted_to_volunteer.rb b/db/migrate/20240923061535_add_terms_accepted_to_volunteer.rb new file mode 100644 index 0000000..406f9e8 --- /dev/null +++ b/db/migrate/20240923061535_add_terms_accepted_to_volunteer.rb @@ -0,0 +1,5 @@ +class AddTermsAcceptedToVolunteer < ActiveRecord::Migration[7.1] + def change + add_column :volunteers, :terms_accepted, :boolean, default: false + end +end diff --git a/docker-compose.yml b/docker-compose.yml index 6a4f288..dd08b39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,15 +26,21 @@ services: POSTGRES_DB: clarion volumes: - pgdata:/var/lib/postgresql/data + ports: + - 127.0.0.1:5432:5432 redis: image: redis:7 + ports: + - 127.0.0.1:6379:6379 mail-dummy: image: python:3.11-slim command: python3 -m smtpd --debug --class DebuggingServer 0.0.0.0:25 expose: - 25 + ports: + - 127.0.0.1:2525:25 volumes: pgdata: diff --git a/lib/initfest/views/public/volunteers/_form.slim b/lib/initfest/views/public/volunteers/_form.slim index a42fdfa..23c020f 100644 --- a/lib/initfest/views/public/volunteers/_form.slim +++ b/lib/initfest/views/public/volunteers/_form.slim @@ -22,5 +22,6 @@ = f.input :food_preferences, collection: Volunteer::FOOD_PREFERENCES, as: :radio_buttons, wrapper: :default, checked: (@volunteer.food_preferences.presence || :none) = f.input :previous_experience = f.input :notes + = f.input :terms_accepted .form-actions = f.button :submit