diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb
index 43a3bb0bef1..0ed11bd3ba2 100644
--- a/app/controllers/competitions_controller.rb
+++ b/app/controllers/competitions_controller.rb
@@ -280,7 +280,6 @@ def new
competitor_limit_enabled: true,
base_entry_fee_lowest_denomination: 0,
guests_entry_fee_lowest_denomination: 0,
- registration_version: :v2,
)
assign_editing_user(@competition)
diff --git a/app/models/competition.rb b/app/models/competition.rb
index c87ddc09018..898cb2a7ad6 100644
--- a/app/models/competition.rb
+++ b/app/models/competition.rb
@@ -96,7 +96,9 @@ class Competition < ApplicationRecord
restricted: 2,
}, prefix: true
- enum :registration_version, [:v1, :v2, :v3], prefix: true, default: :v2
+ NEW_REG_SYSTEM_DEFAULT = :v2
+
+ enum :registration_version, [:v1, :v2, :v3], prefix: true, default: NEW_REG_SYSTEM_DEFAULT
CLONEABLE_ATTRIBUTES = %w(
cityName
@@ -634,7 +636,6 @@ def being_cloned_from
def build_clone
Competition.new(attributes.slice(*CLONEABLE_ATTRIBUTES)).tap do |clone|
clone.being_cloned_from_id = id
- clone.registration_version = :v2
Competition.reflections.each_key do |association_name|
case association_name
@@ -741,11 +742,11 @@ def trainee_delegate_ids
end
def enable_v2_registrations!
- update_column :registration_version, :v2
+ update_column :registration_version, NEW_REG_SYSTEM_DEFAULT
end
def uses_new_registration_service?
- self.registration_version_v2?
+ self.registration_version_v2? || self.registration_version_v3?
end
def should_render_register_v2?(user)
@@ -2409,7 +2410,7 @@ def to_form_data
"admin" => {
"isConfirmed" => confirmed?,
"isVisible" => showAtAll?,
- "registrationVersion" => registration_version.to_s,
+ "usesNewRegistrationSystem" => uses_new_registration_service?,
},
"cloning" => {
"fromId" => being_cloned_from_id,
@@ -2616,7 +2617,7 @@ def self.form_data_to_attributes(form_data)
showAtAll: form_data.dig('admin', 'isVisible'),
being_cloned_from_id: form_data.dig('cloning', 'fromId'),
clone_tabs: form_data.dig('cloning', 'cloneTabs'),
- registration_version: form_data.dig('admin', 'registrationVersion'),
+ registration_version: form_data.dig('admin', 'usesNewRegistrationSystem') ? NEW_REG_SYSTEM_DEFAULT : :v1,
}
end
@@ -2848,7 +2849,7 @@ def self.form_data_json_schema
"properties" => {
"isConfirmed" => { "type" => "boolean" },
"isVisible" => { "type" => "boolean" },
- "usesV2Registrations" => { "type" => "boolean" },
+ "usesNewRegistrationSystem" => { "type" => "boolean" },
},
},
"cloning" => {
diff --git a/app/webpacker/components/CompetitionForm/FormSections/Admin.js b/app/webpacker/components/CompetitionForm/FormSections/Admin.js
index 1d2c76dcd93..8c5afb1e4d1 100644
--- a/app/webpacker/components/CompetitionForm/FormSections/Admin.js
+++ b/app/webpacker/components/CompetitionForm/FormSections/Admin.js
@@ -1,25 +1,17 @@
import React from 'react';
-import { InputBoolean, InputSelect } from '../../wca/FormBuilder/input/FormInputs';
+import { InputBoolean } from '../../wca/FormBuilder/input/FormInputs';
import { useStore } from '../../../lib/providers/StoreProvider';
import SubSection from '../../wca/FormBuilder/SubSection';
-import { useFormObject } from '../../wca/FormBuilder/provider/FormObjectProvider';
-
-const registrationVersions = [{
- key: 'v1', value: 'v1', text: 'Version 1',
-}, {
- key: 'v2', value: 'v2', text: 'Version 2',
-}];
export default function Admin() {
const { isAdminView, isPersisted, canChangeRegistrationSystem } = useStore();
- const { admin: { registrationVersion } } = useFormObject();
if (!isPersisted || !isAdminView) return null;
return (
- x.value === registrationVersion)} disabled={!canChangeRegistrationSystem} />
+
);
}
diff --git a/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js b/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js
index 4741c7844d2..c14ab074b45 100644
--- a/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js
+++ b/app/webpacker/components/CompetitionForm/FormSections/EventRestrictions.js
@@ -27,7 +27,7 @@ export default function EventRestrictions() {
eventLimitation,
},
admin: {
- usesV2Registrations,
+ usesNewRegistrationSystem,
},
} = useFormObject();
@@ -52,7 +52,7 @@ export default function EventRestrictions() {
return (
- { usesV2Registrations && (
+ { usesNewRegistrationSystem && (
diff --git a/app/webpacker/components/CompetitionForm/FormSections/NameDetails.js b/app/webpacker/components/CompetitionForm/FormSections/NameDetails.js
index 9374c0e642b..34e390a535a 100644
--- a/app/webpacker/components/CompetitionForm/FormSections/NameDetails.js
+++ b/app/webpacker/components/CompetitionForm/FormSections/NameDetails.js
@@ -8,14 +8,14 @@ import { useFormObject } from '../../wca/FormBuilder/provider/FormObjectProvider
export default function NameDetails() {
const { hasAnyRegistrations, isPersisted, isAdminView } = useStore();
- const { name, admin: { usesV2Registrations } } = useFormObject();
+ const { name, admin: { usesNewRegistrationSystem } } = useFormObject();
const nameAlreadyShort = !name || name.length <= competitionMaxShortNameLength;
const disableIdAndShortName = !isAdminView && nameAlreadyShort;
// ID change on V1 is always possible, because we have control over the Foreign Keys.
// Otherwise, only competitions without registrations can change their ID.
- const regSystemSupportsIdChange = !usesV2Registrations || !hasAnyRegistrations;
+ const regSystemSupportsIdChange = !usesNewRegistrationSystem || !hasAnyRegistrations;
return (
<>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f93126a47ec..a02147699fd 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1619,7 +1619,7 @@ en:
admin:
is_confirmed: "Do not let organizers edit this competition"
is_visible: "Make competition visible to the public"
- registration_version: "Which registration service version is used"
+ uses_new_registrations: "Use the new Registration System"
competition_id: "ID"
name: "Name"
short_name: "Competition short name"
@@ -1700,7 +1700,7 @@ en:
admin:
is_confirmed: ""
is_visible: ""
- registration_version: "If this is disabled, changing the registration system will cause technical issues. Please contact WST for assistance if you still need to change the registration system."
+ uses_new_registrations: "If this is disabled, changing the registration system will cause technical issues. Please contact WST for assistance if you still need to change the registration system."
competition_id: ""
name: "The full name of the competition including the year at the end (e.g., Danish Open 2016). Be sure to capitalize. The name must contain only alphanumeric characters, dashes(-), ampersands(&), periods(.), colons(:), apostrophes('), and spaces( )."
short_name: "A short name for displaying. If the name of the competition is below %{short_name_limit} characters this should not be edited and should be the same as the normal name."
diff --git a/db/migrate/20241025161404_make_registration_version_an_enum.rb b/db/migrate/20241025161404_make_registration_version_an_enum.rb
index c66454371e4..0f93b6fd5cf 100644
--- a/db/migrate/20241025161404_make_registration_version_an_enum.rb
+++ b/db/migrate/20241025161404_make_registration_version_an_enum.rb
@@ -5,7 +5,7 @@ def up
add_column :Competitions, :registration_version, :integer, default: 0, null: false
# Update values based on the old boolean column
- Competition.where(uses_v2_registrations: true).update_all(registration_version: 1)
+ Competition.where(uses_v2_registrations: true).update_all(registration_version: Competition.registration_versions[:v2])
# Remove the old column
remove_column :Competitions, :uses_v2_registrations
@@ -16,7 +16,7 @@ def down
add_column :Competitions, :uses_v2_registrations, :boolean, default: false, null: false
# Map back enum values to the boolean
- Competition.where(registration_version: 1).update_all(uses_v2_registrations: true)
+ Competition.where(registration_version: Competition.registration_versions[:v2]).update_all(uses_v2_registrations: true)
# Remove the enum column and rename the boolean column back
remove_column :Competitions, :registration_version