diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 62a47fb9b4..f5a155421e 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -6,22 +6,23 @@ class RegistrationsController < Devise::RegistrationsController prepend_before_action :disable_destroy, only: [:destroy] def new - respond_to { |format| format.html { redirect_with_authentication('signUp') } } + respond_to { |format| format.html { redirect_with_authentication("signUp") } } end private def check_captcha + return if RootSite.instance.disable_captcha? return if verify_recaptcha configure_permitted_parameters # we prepended, so this won't have run self.resource = resource_class.new sign_up_params resource.validate # Look for any other validation errors besides Recaptcha - resource.errors.add :recaptcha, 'failed verification' + resource.errors.add :recaptcha, "failed verification" respond_with resource end def disable_destroy - redirect_to root_path, alert: 'To delete your account, please email the site administrators.' + redirect_to root_path, alert: "To delete your account, please email the site administrators." end end diff --git a/app/models/root_site.rb b/app/models/root_site.rb index dd460429c9..2e1285f1f2 100644 --- a/app/models/root_site.rb +++ b/app/models/root_site.rb @@ -5,6 +5,7 @@ # Table name: root_sites # # id :bigint not null, primary key +# disable_captcha :boolean default(FALSE), not null # site_name :text # default_layout_id :bigint # root_page_id :bigint diff --git a/app/presenters/convention_reports_presenter.rb b/app/presenters/convention_reports_presenter.rb index 9d2073f24b..a38d2ec217 100644 --- a/app/presenters/convention_reports_presenter.rb +++ b/app/presenters/convention_reports_presenter.rb @@ -20,6 +20,7 @@ def sales_count_by_product_and_payment_amount "COALESCE(price_per_item_cents, 0)", "COALESCE(price_per_item_currency, #{ActiveRecord::Base.connection.quote(convention.default_currency_code_or_site_default)})" ) + .where("product_id IS NOT NULL") .pluck( :product_id, :status, @@ -27,7 +28,7 @@ def sales_count_by_product_and_payment_amount Arel.sql( "COALESCE(price_per_item_currency, #{ActiveRecord::Base.connection.quote(convention.default_currency_code_or_site_default)})" ), - Arel.sql("SUM(quantity) sum_quantity") + Arel.sql("COALESCE(SUM(quantity), 0) sum_quantity") ) grouped_count_data.map do |product_id, status, amount_cents, amount_currency, sum_quantity| diff --git a/db/migrate/20240916155847_add_disable_captcha_to_root_sites.rb b/db/migrate/20240916155847_add_disable_captcha_to_root_sites.rb new file mode 100644 index 0000000000..224502abb0 --- /dev/null +++ b/db/migrate/20240916155847_add_disable_captcha_to_root_sites.rb @@ -0,0 +1,5 @@ +class AddDisableCaptchaToRootSites < ActiveRecord::Migration[7.2] + def change + add_column :root_sites, :disable_captcha, :boolean, null: false, default: false + end +end diff --git a/db/structure.sql b/db/structure.sql index c20ac95ea5..fe6727c3b8 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2422,7 +2422,8 @@ CREATE TABLE public.root_sites ( id bigint NOT NULL, site_name text, root_page_id bigint, - default_layout_id bigint + default_layout_id bigint, + disable_captcha boolean DEFAULT false NOT NULL ); @@ -6119,6 +6120,7 @@ ALTER TABLE ONLY public.cms_files_pages SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +('20240916155847'), ('20240807155222'), ('20240717150224'), ('20240620014115'), diff --git a/test/factories/root_sites.rb b/test/factories/root_sites.rb index c792b12d87..a20aa9d2cc 100644 --- a/test/factories/root_sites.rb +++ b/test/factories/root_sites.rb @@ -4,6 +4,7 @@ # Table name: root_sites # # id :bigint not null, primary key +# disable_captcha :boolean default(FALSE), not null # site_name :text # default_layout_id :bigint # root_page_id :bigint @@ -19,7 +20,6 @@ # fk_rails_... (root_page_id => pages.id) # # rubocop:enable Layout/LineLength, Lint/RedundantCopDisableDirective -# rubocop:disable Metrics/LineLength, Lint/RedundantCopDisableDirective FactoryBot.define do factory :root_site do site_name { "The Root Site" } diff --git a/test/models/root_site_test.rb b/test/models/root_site_test.rb index 92c0b8b254..dc42c395ce 100644 --- a/test/models/root_site_test.rb +++ b/test/models/root_site_test.rb @@ -4,6 +4,7 @@ # Table name: root_sites # # id :bigint not null, primary key +# disable_captcha :boolean default(FALSE), not null # site_name :text # default_layout_id :bigint # root_page_id :bigint @@ -19,7 +20,6 @@ # fk_rails_... (root_page_id => pages.id) # # rubocop:enable Layout/LineLength, Lint/RedundantCopDisableDirective -# rubocop:disable Layout/LineLength, Lint/RedundantCopDisableDirective require "test_helper" class RootSiteTest < ActiveSupport::TestCase