Files
thrillwiki_django_no_react/.clinerules/rich-choice-objects.md
pacnpal c2c26cfd1d Add comprehensive API documentation for ThrillWiki integration and features
- Introduced Next.js integration guide for ThrillWiki API, detailing authentication, core domain APIs, data structures, and implementation patterns.
- Documented the migration to Rich Choice Objects, highlighting changes for frontend developers and enhanced metadata availability.
- Fixed the missing `get_by_slug` method in the Ride model, ensuring proper functionality of ride detail endpoints.
- Created a test script to verify manufacturer syncing with ride models, ensuring data integrity across related models.
2025-09-16 11:29:17 -04:00

1.4 KiB

Brief overview

Mandatory use of Rich Choice Objects system instead of Django tuple-based choices for all choice fields in ThrillWiki project.

Rich Choice Objects enforcement

  • NEVER use Django tuple-based choices (e.g., choices=[('VALUE', 'Label')]) - ALWAYS use RichChoiceField
  • All choice fields MUST use RichChoiceField(choice_group="group_name", domain="domain_name") pattern
  • Choice definitions MUST be created in domain-specific choices.py files using RichChoice dataclass
  • All choices MUST include rich metadata (color, icon, description, css_class at minimum)
  • Choice groups MUST be registered with global registry using register_choices() function
  • Import choices in domain __init__.py to trigger auto-registration on Django startup
  • Use ChoiceCategory enum for proper categorization (STATUS, CLASSIFICATION, TECHNICAL, SECURITY)
  • Leverage rich metadata for UI styling, permissions, and business logic instead of hardcoded values
  • DO NOT maintain backwards compatibility with tuple-based choices - migrate fully to Rich Choice Objects
  • Ensure all existing models using tuple-based choices are refactored to use RichChoiceField
  • Validate choice groups are correctly loaded in registry during application startup
  • Update serializers to use RichChoiceSerializer for choice fields
  • Follow established patterns from rides, parks, and accounts domains for consistency