Decouple YouTube live stream updates from request/response in edit_match admin view#173
Open
Decouple YouTube live stream updates from request/response in edit_match admin view#173
Conversation
…tch admin view - Move YouTube API logic from pre_save_callback to Django signal handler - Replace request.build_absolute_uri() with Site model for URL generation - Add handle_match_youtube_updates signal connected to Match pre_save - Remove pre_save_callback and related imports from admin.py - Add proper null checking for play_at field in signal handler - Fix video links appending logic in signal handler This decouples YouTube operations from the admin view request/response cycle while maintaining the same functionality. All Match saves will now trigger YouTube updates via signal handlers instead of callbacks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Gary Reynolds <goodtune@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
- Move set_youtube_thumbnail import to top of signals/matches.py - Rename handle_match_youtube_updates to match_youtube_sync - Update all references in __init__.py and apps.py Co-authored-by: Gary Reynolds <goodtune@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Move set_youtube_thumbnail import inside match_youtube_sync function to avoid circular dependency between signals and tasks modules. Co-authored-by: Gary Reynolds <goodtune@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
- Add new YouTubeSignalHandlerTests class with 8 test cases covering all signal handler scenarios - Test guard clause, broadcast creation/update/deletion, video management, and title formatting - Update existing admin tests to mock and verify signal handler execution - Properly mock YouTube API calls and verify task queuing behavior - Replace references to old pre_save_callback with signal handler in test comments 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Gary Reynolds <goodtune@users.noreply.github.com>
Conflicts: - tournamentcontrol/competition/admin.py - tournamentcontrol/competition/tests/test_competition_admin.py
Resolved merge conflict by integrating template-based YouTube live stream functionality from #206 into the signal handler approach from #172. Changes: - Removed `pre_save_callback` from `edit_match` admin view - Updated `match_youtube_sync` signal handler to use template rendering - Added hierarchical template fallback for title and description - Added safety check for `start_time is None` - Removed unused `render_to_string` import from admin.py 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add generic exception handler in `match_youtube_sync` for API errors - Generate fallback competition URL when match has no PK yet - Fix mock paths to use `tournamentcontrol.competition.tasks` instead of signals module - Add `@override_settings(ROOT_URLCONF)` to test classes for proper URL resolution - Update test fixtures to bypass signals during setup to test specific save scenarios - Add admin URLs to test `urlpatterns` for complete integration testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #172
This PR decouples YouTube live stream updates from the request/response cycle in the edit_match admin view by switching from callback functions to Django signal handlers.
Changes
Benefits
Generated with Claude Code