|
367 | 367 | end |
368 | 368 | puts "Done assigning categories and sectors." |
369 | 369 |
|
| 370 | +# A few unpublished (non-canonical) sectors that still carry taggings, so the |
| 371 | +# taggings admin has data exercising the "tagged but hidden" state. The base |
| 372 | +# db/seeds.rb only creates the canonical SECTOR_TYPES; these are dev-only and |
| 373 | +# stay unpublished (they're not on the canonical list). |
| 374 | +puts "Creating unpublished sectors with taggings…" |
| 375 | +workshop_pool = Workshop.all.to_a |
| 376 | +[ "Animal-Assisted Therapy", "School Counseling", "Youth Mentorship" ].each do |sector_name| |
| 377 | + sector = Sector.where("LOWER(name) = LOWER(?)", sector_name).first_or_create!(name: sector_name) |
| 378 | + sector.update!(published: false) |
| 379 | + |
| 380 | + workshop_pool.sample(rand(2..4)).each do |workshop| |
| 381 | + SectorableItem.find_or_create_by!( |
| 382 | + sector_id: sector.id, |
| 383 | + sectorable_type: "Workshop", |
| 384 | + sectorable_id: workshop.id |
| 385 | + ) |
| 386 | + end |
| 387 | +end |
| 388 | +puts "Done creating unpublished sectors with taggings." |
| 389 | + |
| 390 | +# A few unpublished (non-canonical) categories that still carry taggings, so the |
| 391 | +# taggings admin has data exercising the "tagged but hidden" state for categories |
| 392 | +# too. The base db/seeds.rb only creates canonical categories; these are dev-only, |
| 393 | +# attached to an existing type so they group correctly on the tags page, and stay |
| 394 | +# unpublished (they're not on any canonical list). |
| 395 | +puts "Creating unpublished categories with taggings…" |
| 396 | +art_type = CategoryType.where("LOWER(name) = LOWER(?)", "ArtType").first_or_create!(name: "ArtType", published: true) |
| 397 | +[ "Sand Art", "Found-Object Sculpture", "Shadow Puppetry" ].each do |category_name| |
| 398 | + category = Category.where("LOWER(name) = LOWER(?)", category_name) |
| 399 | + .first_or_create!(name: category_name, category_type: art_type) |
| 400 | + category.update!(published: false) |
| 401 | + |
| 402 | + workshop_pool.sample(rand(2..4)).each do |workshop| |
| 403 | + CategorizableItem.find_or_create_by!( |
| 404 | + category_id: category.id, |
| 405 | + categorizable_type: "Workshop", |
| 406 | + categorizable_id: workshop.id |
| 407 | + ) |
| 408 | + end |
| 409 | +end |
| 410 | +puts "Done creating unpublished categories with taggings." |
| 411 | + |
370 | 412 | puts "Creating Workshop Variations…" |
371 | 413 | # rubocop:disable Style/PercentLiteralDelimiters |
372 | 414 | variations = [ |
|
0 commit comments