Skip to content

Comments

feat: importing from an existing media opens the correct tab and pre-fills the search#59

Merged
PascalRepond merged 1 commit intomainfrom
rep-dev
Jan 21, 2026
Merged

feat: importing from an existing media opens the correct tab and pre-fills the search#59
PascalRepond merged 1 commit intomainfrom
rep-dev

Conversation

@PascalRepond
Copy link
Owner

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

The pull request enhances the media import workflow by passing media context (type and title) from the edit form to the import view. The view maps media types to appropriate data sources (FILM/TV→tmdb, GAME→igdb, BOOK/COMIC→openlibrary, MUSIC→musicbrainz) and exposes default source and search query to the template, which then conditionally displays the correct source tab and prefills search fields.

Changes

Cohort / File(s) Summary
View Logic
src/core/views.py
Adds media_type-to-source mapping (FILM/TV→tmdb, GAME→igdb, BOOK/COMIC→openlibrary, MUSIC→musicbrainz) with fallback to tmdb for unknown types. Exposes default_source and default_query (from title) to template context.
Template Integration
src/templates/base/media_edit.html
Appends media_type and title query parameters to media_import link when editing existing media objects.
Import Template UI
src/templates/base/media_import.html
Conditionally shows/hides source tabs and panels based on default_source value. Prefills search input fields with default_query and conditionally triggers automatic search load when a default query is present for the active source.
Test Coverage
src/tests/core/test_views.py
Introduces TestMediaImportView suite covering logged-in access, media_type→source mapping, unknown type handling, context passing, and special character handling in titles.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PascalRepond/datakult#56: Implements MusicBrainz integration for the media import view, directly related to the MusicBrainz source mapping logic in this PR.
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author; however, the title and changeset clearly convey the purpose of the changes. Add a brief description explaining the feature, its benefits, and any relevant context to help reviewers understand the implementation rationale.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: opening the correct import tab and pre-filling search based on existing media context.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PascalRepond PascalRepond merged commit 8054eaf into main Jan 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant