Skip to content

Commit 9bb45d6

Browse files
committed
Fix a bunch of bugs in the cloner
1 parent 40501f3 commit 9bb45d6

5 files changed

Lines changed: 13 additions & 19 deletions

File tree

app/graphql/mutations/create_convention.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ class Mutations::CreateConvention < Mutations::BaseMutation
1212
define_authorization_check { |_args| policy(Convention.new).create? }
1313

1414
def resolve(convention:, clone_convention_id: nil, cms_content_set_name: nil, organization_id: nil)
15-
convention_data =
16-
convention.to_h.merge(
17-
"organization_id" => organization_id,
18-
"updated_by" => current_user,
19-
"signup_automation_mode" => "none"
20-
)
15+
convention_data = convention.to_h.merge("organization_id" => organization_id, "updated_by" => current_user)
2116
if convention.maximum_event_signups
2217
convention_data["maximum_event_signups"] = process_scheduled_value_input(convention.maximum_event_signups)
2318
end

app/services/clone_convention_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def inner_call
4242
ContentCloners::DepartmentsCloner,
4343
ContentCloners::EventCategoriesCloner,
4444
ContentCloners::StaffPositionsCloner,
45-
ContentCloners::UserActivityAlertsCloner,
4645
ContentCloners::CmsContentCloner,
46+
ContentCloners::UserActivityAlertsCloner,
4747
ContentCloners::RoomsCloner,
4848
ContentCloners::TicketTypesCloner,
4949
ContentCloners::StoreContentCloner

app/services/content_cloners/cms_content_cloner.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ def clone(convention)
55
clone_pages(convention)
66
clone_cms_navigation_items(convention)
77
clone_cms_files(convention)
8-
clone_cms_content_group_contents(convention)
8+
clone_cms_content_group_contents
99
clone_notification_templates(convention)
1010

1111
convention.update!(
1212
root_page: @id_maps[:pages][source_convention.root_page_id],
13-
default_layout: @id_maps[:cms_layouts][source_convention.default_layout_id],
14-
user_con_profile_form: @id_maps[:forms][source_convention.user_con_profile_form_id]
13+
default_layout: @id_maps[:cms_layouts][source_convention.default_layout_id]
1514
)
1615
end
1716

@@ -60,10 +59,10 @@ def clone_cms_files(convention)
6059
end
6160
end
6261

63-
def clone_cms_content_group_contents(convention)
62+
def clone_cms_content_group_contents
6463
Rails.logger.info("Cloning CMS content group contents")
6564

66-
convention.cms_content_groups.find_each do |cms_content_group|
65+
source_convention.cms_content_groups.find_each do |cms_content_group|
6766
cloned_cms_content_group = @id_maps.fetch(:cms_content_groups).fetch(cms_content_group.id)
6867

6968
%i[pages cms_partials cms_layouts].each do |content_type|
@@ -87,6 +86,7 @@ def clone_notification_templates(convention)
8786

8887
cloned_notification_template.notification_destinations.destroy_all
8988
destination_id_map = clone_notification_destinations(notification_template, cloned_notification_template)
89+
@id_maps[:notification_destinations] = {}
9090
@id_maps[:notification_destinations].merge!(destination_id_map)
9191
end
9292
end

app/services/content_cloners/content_cloner_base.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,13 @@ def shift_scheduled_value_by_convention_distance(convention, value)
4545
shift_scheduled_value(value, convention.starts_at - source_convention.starts_at)
4646
end
4747

48-
def clone_user_con_profile(user_con_profile)
48+
def clone_user_con_profile(convention, user_con_profile)
4949
@id_maps[:user_con_profiles] ||= {}
50-
cloned_user_con_profile = @id_maps.fetch[:user_con_profiles][user_con_profile.id]
50+
cloned_user_con_profile = @id_maps.fetch(:user_con_profiles)[user_con_profile.id]
5151
return cloned_user_con_profile if cloned_user_con_profile
5252

5353
cloned_user_con_profile =
54-
SetupUserConProfileService
55-
.new(convention: cloned_source.convention, user: @id_maps.fetch(:users)[user_con_profile.user_id])
56-
.call!
57-
.user_con_profile
54+
SetupUserConProfileService.new(convention:, user: User.find(user_con_profile.user_id)).call!.user_con_profile
5855
@id_maps[:user_con_profiles][user_con_profile.id] = cloned_user_con_profile
5956
cloned_user_con_profile
6057
end
@@ -66,7 +63,7 @@ def clone_notification_destinations(source, cloned_source)
6663
) do |notification_destination, cloned_notification_destination|
6764
if notification_destination.user_con_profile_id
6865
cloned_notification_destination.user_con_profile =
69-
clone_user_con_profile(notification_destination.user_con_profile)
66+
clone_user_con_profile(cloned_source.convention, notification_destination.user_con_profile)
7067
end
7168

7269
cloned_notification_destination.staff_position =

app/services/content_cloners/early_cms_content_cloner.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ class ContentCloners::EarlyCmsContentCloner < ContentCloners::ContentClonerBase
33
def clone(convention)
44
clone_forms(convention)
55
clone_cms_content_groups(convention)
6+
7+
convention.update!(user_con_profile_form: @id_maps[:forms][source_convention.user_con_profile_form_id])
68
end
79

810
private

0 commit comments

Comments
 (0)