Conversation
Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
…ethod Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
| def get_color(self): | ||
| """ | ||
| Get the division color, falling back to a default based on order. | ||
| """ | ||
| if self.color: | ||
| return self.color | ||
| # Default colors based on division order (matching CSS) | ||
| default_colors = { | ||
| 1: "#e74c3c", # Red | ||
| 2: "#3498db", # Blue | ||
| 3: "#2ecc71", # Green | ||
| 4: "#f39c12", # Orange | ||
| 5: "#9b59b6", # Purple | ||
| 6: "#1abc9c", # Teal | ||
| 7: "#e67e22", # Dark Orange | ||
| 8: "#34495e", # Dark Gray | ||
| } | ||
| return default_colors.get(self.order, "#6c757d") # Gray as ultimate fallback |
There was a problem hiding this comment.
@copilot let's make the colour mandatory and use a data migration for the historical cases instead.
On creation of a division, the colour widget default value should be randomised.
There was a problem hiding this comment.
Done in commit c562ab9. Division color is now mandatory with generate_random_color() as the default. A data migration (0058) populates historical records using order-based colors. The color picker widget will show a random bright color on division creation.
| """ | ||
| if self.color: | ||
| return self.color | ||
| # Default to light green (matching current CSS default for scheduled items) |
There was a problem hiding this comment.
@copilot this comment doesn't date well because the current value isn't a thing anymore after the change.
We can just make this the default value (make it a db_default too) so historical values are populated.
There was a problem hiding this comment.
Done in commit c562ab9. Stage color now uses db_default="#e8f5e8" and the comment has been updated to remove the temporal reference. Historical values are automatically populated by the database default.
There was a problem hiding this comment.
@copilot rethink the testing based on the other comments in this review.
There should also be some tests of the actual UI with the framework tests.
The Division and Stage factories probably need an update too.
There was a problem hiding this comment.
Done in commit c562ab9. Tests completely rethought:
- Added ColorGenerationTests for the random color function
- Updated Division/Stage tests to reflect mandatory fields
- Fixed test_add_division to include color in POST data
- Added E2E tests (test_visual_scheduler_colors.py) with 3 browser tests verifying division headers, match borders, and stage backgrounds
- Updated DivisionFactory and StageFactory with color generation
All tests passing: 15 unit, 69 admin, 3 E2E.
…t for Stage Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
…on logic Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(populate_division_colors, reverse_population), |
| field=models.CharField( | ||
| default=tournamentcontrol.competition.models.generate_random_color, | ||
| help_text="Color for division in the visual scheduler. Affects the left border of match cards and division headers.", | ||
| max_length=7, | ||
| verbose_name="Color", | ||
| ), |
There was a problem hiding this comment.
@copilot we should have validations on this being a valid colour expression using regular expressions? If it can be enforced at the database as well that would be ideal.
There was a problem hiding this comment.
Done in commit 7bf41f5. Added RegexValidator to both Division and Stage color fields enforcing ^#[0-9a-fA-F]{6}$ pattern. Also added database-level CHECK constraints using CheckConstraint with the same regex pattern for validation at the database level. Added 6 new tests covering validation scenarios.
There was a problem hiding this comment.
@copilot the tests should take screenshots and make them available as artifacts of the build in actions.
There was a problem hiding this comment.
Done in commit 3118f76. All E2E tests now capture full-page screenshots saved to tests/screenshots/:
division_header_colors.pngmatch_card_border_colors.pngmatch_card_background_colors.png
Updated GitHub Actions workflow to upload screenshots as artifacts (retained for 7 days). The SCREENSHOTS_DIR environment variable can be configured for different paths in CI.
…noop migration Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
…load Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
|
@copilot it might be unrelated to these changes but the match cards in the e2e tests seem to have |
Co-authored-by: goodtune <286798+goodtune@users.noreply.github.com>
Fixed in commit 35d520e. The issue was a JavaScript template literal syntax error on line 273 of |
|
@claude please review this pull request and give your verdict on the quality of it. |
|
Claude finished @goodtune's task —— View job PR Review: Add mandatory color fields with validation to Division and StageReview Tasks
Analysis CompleteAfter thoroughly analyzing the code changes, I can provide a comprehensive review of this pull request. 🎯 VERDICT: HIGH QUALITY IMPLEMENTATION - APPROVEDExcellent Code Quality Areas1. Models Design (tournamentcontrol/competition/models.py)
2. Migration Strategy (0057/0058)
3. Validation Approach
4. Test Coverage (test_color_fields.py)
Implementation HighlightsTemplate Integration
Admin Integration
CI/CD Enhancement
Technical Strengths
Code Review Feedback IncorporationThe PR successfully addressed all review feedback:
Minor Observations
Overall AssessmentThis is a textbook example of how to implement a feature in Django:
Recommendation: ✅ APPROVE - This PR demonstrates excellent Django development practices and is ready for production deployment. |

Implementation Plan: Drag & Drop Match Grid Color Settings - COMPLETE
All Code Review Feedback Addressed ✅
Latest Fix (addressing comment 3826120054):
JavaScript Template Literal Bug Fix ✅
visual_schedule.htmlline 273Round{match.round}toRound ${match.round}(added missing$)Complete Summary
Models
generate_random_color()helper for bright colors^#[0-9a-fA-F]{6}$Migrations
0057_add_color_fields.py- Schema with validators and constraints0058_populate_color_fields.py- Data migration usingRunPython.noopTemplates
getMatchLabel()Tests
CI/CD
SCREENSHOTS_DIRconfigurableTest Results
Screenshot
The visual scheduler now correctly displays match information with proper round numbers and custom division/stage colors:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.