Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/graphql/mutations/create_convention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ class Mutations::CreateConvention < Mutations::BaseMutation
define_authorization_check { |_args| policy(Convention.new).create? }

def resolve(convention:, clone_convention_id: nil, cms_content_set_name: nil, organization_id: nil)
convention_data =
convention.to_h.merge(
"organization_id" => organization_id,
"updated_by" => current_user,
"signup_automation_mode" => "none"
)
convention_data = convention.to_h.merge("organization_id" => organization_id, "updated_by" => current_user)
if convention.maximum_event_signups
convention_data["maximum_event_signups"] = process_scheduled_value_input(convention.maximum_event_signups)
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/clone_convention_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def inner_call
ContentCloners::DepartmentsCloner,
ContentCloners::EventCategoriesCloner,
ContentCloners::StaffPositionsCloner,
ContentCloners::UserActivityAlertsCloner,
ContentCloners::CmsContentCloner,
ContentCloners::UserActivityAlertsCloner,
ContentCloners::RoomsCloner,
ContentCloners::TicketTypesCloner,
ContentCloners::StoreContentCloner
Expand Down
10 changes: 5 additions & 5 deletions app/services/content_cloners/cms_content_cloner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ def clone(convention)
clone_pages(convention)
clone_cms_navigation_items(convention)
clone_cms_files(convention)
clone_cms_content_group_contents(convention)
clone_cms_content_group_contents
clone_notification_templates(convention)

convention.update!(
root_page: @id_maps[:pages][source_convention.root_page_id],
default_layout: @id_maps[:cms_layouts][source_convention.default_layout_id],
user_con_profile_form: @id_maps[:forms][source_convention.user_con_profile_form_id]
default_layout: @id_maps[:cms_layouts][source_convention.default_layout_id]
)
end

Expand Down Expand Up @@ -60,10 +59,10 @@ def clone_cms_files(convention)
end
end

def clone_cms_content_group_contents(convention)
def clone_cms_content_group_contents
Rails.logger.info("Cloning CMS content group contents")

convention.cms_content_groups.find_each do |cms_content_group|
source_convention.cms_content_groups.find_each do |cms_content_group|
cloned_cms_content_group = @id_maps.fetch(:cms_content_groups).fetch(cms_content_group.id)

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

cloned_notification_template.notification_destinations.destroy_all
destination_id_map = clone_notification_destinations(notification_template, cloned_notification_template)
@id_maps[:notification_destinations] = {}
@id_maps[:notification_destinations].merge!(destination_id_map)
end
end
Expand Down
11 changes: 4 additions & 7 deletions app/services/content_cloners/content_cloner_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ def shift_scheduled_value_by_convention_distance(convention, value)
shift_scheduled_value(value, convention.starts_at - source_convention.starts_at)
end

def clone_user_con_profile(user_con_profile)
def clone_user_con_profile(convention, user_con_profile)
@id_maps[:user_con_profiles] ||= {}
cloned_user_con_profile = @id_maps.fetch[:user_con_profiles][user_con_profile.id]
cloned_user_con_profile = @id_maps.fetch(:user_con_profiles)[user_con_profile.id]
return cloned_user_con_profile if cloned_user_con_profile

cloned_user_con_profile =
SetupUserConProfileService
.new(convention: cloned_source.convention, user: @id_maps.fetch(:users)[user_con_profile.user_id])
.call!
.user_con_profile
SetupUserConProfileService.new(convention:, user: User.find(user_con_profile.user_id)).call!.user_con_profile
@id_maps[:user_con_profiles][user_con_profile.id] = cloned_user_con_profile
cloned_user_con_profile
end
Expand All @@ -66,7 +63,7 @@ def clone_notification_destinations(source, cloned_source)
) do |notification_destination, cloned_notification_destination|
if notification_destination.user_con_profile_id
cloned_notification_destination.user_con_profile =
clone_user_con_profile(notification_destination.user_con_profile)
clone_user_con_profile(cloned_source.convention, notification_destination.user_con_profile)
end

cloned_notification_destination.staff_position =
Expand Down
2 changes: 2 additions & 0 deletions app/services/content_cloners/early_cms_content_cloner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class ContentCloners::EarlyCmsContentCloner < ContentCloners::ContentClonerBase
def clone(convention)
clone_forms(convention)
clone_cms_content_groups(convention)

convention.update!(user_con_profile_form: @id_maps[:forms][source_convention.user_con_profile_form_id])
end

private
Expand Down
Loading