Skip to content

Commit 63715fe

Browse files
maebealeclaude
andcommitted
Seed CE-requested registrants and CE hours details on trainings
So the CE hours feature has demoable data: mark Amy plus four other registrants as CE-credit requested, and give both facilitator trainings CE hours details so the ticket call-out actually surfaces. Make the named-registration seed idempotent (find_or_initialize) so the CE flag applies on re-seed instead of being skipped by the create-only guard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 133b8d5 commit 63715fe

1 file changed

Lines changed: 52 additions & 12 deletions

File tree

db/seeds/dev/events_management.rb

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,46 @@
316316
HTML
317317
end
318318

319+
# Seed the "CE hours" details — the continuing-education requirements, payment,
320+
# and sign-in rules that used to live in a long CE confirmation email. Shown on its
321+
# own ticket-linked page (and via the prominent indigo call-out on the ticket) for
322+
# registrants who requested CE credit. A custom label demonstrates that the heading
323+
# is admin-editable. Only set when blank so admin edits survive a re-seed.
324+
if flagship && flagship.ce_hours_details.blank?
325+
flagship.update!(ce_hours_details_label: "Continuing education", ce_hours_details: <<~HTML.strip)
326+
<p>This training is approved by the California Association of Marriage and Family Therapists (CAMFT, provider #000000) for <strong>12 CE hours</strong>. AWBW is approved to sponsor continuing education for LMFTs, LCSWs, LPCCs, and LEPs.</p>
327+
<h3>Before the training</h3>
328+
<ul>
329+
<li>Provide your license type and license number when you register — we cannot issue a CE certificate without it.</li>
330+
<li>CE hours carry a separate $25 processing fee, payable with your registration.</li>
331+
</ul>
332+
<h3>During the training</h3>
333+
<ul>
334+
<li>You must sign in and out each day. CE hours are awarded only for full attendance — partial credit is not available.</li>
335+
<li>Arrive on time; late arrivals or early departures may forfeit CE eligibility.</li>
336+
</ul>
337+
<h3>After the training</h3>
338+
<ul>
339+
<li>Complete the post-training evaluation within one week.</li>
340+
<li>Your CE certificate will be emailed within three weeks of the training.</li>
341+
</ul>
342+
<p>Questions about continuing education? Reach out and our team will follow up with details.</p>
343+
HTML
344+
end
345+
346+
# The trauma-informed training also offers CE hours, with the default label.
347+
trauma = Event.find_by(title: "Facilitator Training: Trauma-Informed Art Practices")
348+
if trauma && trauma.ce_hours_details.blank?
349+
trauma.update!(ce_hours_details: <<~HTML.strip)
350+
<p>This training is approved by CAMFT (provider #000000) for <strong>18 CE hours</strong> across its three days.</p>
351+
<ul>
352+
<li>Provide your license type and number at registration; a $25 CE processing fee applies.</li>
353+
<li>Daily sign-in/sign-out is required — CE hours are awarded for full attendance only.</li>
354+
<li>Complete the post-training evaluation to receive your certificate within three weeks.</li>
355+
</ul>
356+
HTML
357+
end
358+
319359
puts "Creating Event Registrations…"
320360

321361
# Key people for named scenarios
@@ -384,9 +424,9 @@
384424
# Kim Davis: cancelled (has user)
385425
if facilitator_training
386426
[
387-
{ person: amy_person, status: "registered", scholarship_requested: true },
388-
{ person: maria_j, status: "registered" },
389-
{ person: anna_g, status: "attended" },
427+
{ person: amy_person, status: "registered", scholarship_requested: true, ce_credit_requested: true },
428+
{ person: maria_j, status: "registered", ce_credit_requested: true },
429+
{ person: anna_g, status: "attended", ce_credit_requested: true },
390430
{ person: mario_j, status: "registered" },
391431
{ person: kim_d, status: "cancelled" }
392432
].each do |data|
@@ -402,8 +442,8 @@
402442
# Linda Williams: no_show (no user)
403443
if trauma_training
404444
[
405-
{ person: sarah_s, status: "registered" },
406-
{ person: jessica_b, status: "registered", scholarship_requested: true },
445+
{ person: sarah_s, status: "registered", ce_credit_requested: true },
446+
{ person: jessica_b, status: "registered", scholarship_requested: true, ce_credit_requested: true },
407447
{ person: angel_g, status: "registered" },
408448
{ person: linda_w, status: "no_show" }
409449
].each do |data|
@@ -461,14 +501,14 @@
461501
# Create all registrations
462502
registrations_data.each do |data|
463503
next unless data[:event] && data[:person]
464-
next if EventRegistration.exists?(event: data[:event], registrant: data[:person])
465504

466-
EventRegistration.create!(
467-
event: data[:event],
468-
registrant: data[:person],
469-
status: data[:status] || "registered",
470-
scholarship_requested: data[:scholarship_requested] || false
471-
)
505+
registration = EventRegistration.find_or_initialize_by(event: data[:event], registrant: data[:person])
506+
registration.status = data[:status] || "registered" if registration.new_record?
507+
registration.scholarship_requested ||= data[:scholarship_requested] || false
508+
# Keep the CE flag in sync on re-seed so the named CE scenarios survive an
509+
# existing DB (the find_or_initialize guard above no longer recreates them).
510+
registration.ce_credit_requested = data[:ce_credit_requested] || false
511+
registration.save!
472512
end
473513

474514
# Give the flagship training its demo cohort: top up to 10 active registrants with

0 commit comments

Comments
 (0)