Skip to content

admin: editable MB work IDs and alternate titles on song detail#216

Merged
dprodger merged 1 commit into
mainfrom
admin-song-mb-id-alt-titles
Jun 14, 2026
Merged

admin: editable MB work IDs and alternate titles on song detail#216
dprodger merged 1 commit into
mainfrom
admin-song-mb-id-alt-titles

Conversation

@dprodger

Copy link
Copy Markdown
Owner

Summary

Adds inline editing to the admin song detail page for MusicBrainz work IDs and alternate titles.

  • MB Work ID and Secondary MB Work ID are both shown and editable. Entering an ID runs a MusicBrainz work lookup (cached via MusicBrainzSearcher) that surfaces the id, title, and composer/writer/lyricist credits. Save is gated on a successful lookup, so an unverified ID can't be persisted — editing the field after a lookup re-disables Save. Slots that already hold a value get a Clear button.
  • Alternate titles render under the song title as chips, with an add/remove editor that saves to songs.alt_titles.

Endpoints

  • GET /admin/musicbrainz/work/<id>/lookup — UUID-validated; returns {id, title, composers:[{name,type}]}
  • POST /admin/songs/<id>/mb-idslot: primary|second, set or clear
  • POST /admin/songs/<id>/alt-titles — replaces alt_titles (trim/de-dupe/empty→NULL)

CSRF is handled automatically by the existing static/js/admin.js fetch wrapper.

Verification

  • admin.py compiles; all three routes register in the app URL map.
  • MB lookup + composer extraction tested live against a real work ID.
  • Template renders without Jinja errors; both MB rows expose editors; Add/Clear logic correct for empty vs. populated slots.
  • Both inline <script> blocks pass node --check.

Live DB write tests were not run, since the local .env DATABASE_URL points at production.

Note

This screen edits the second_mb_id value only — it does not trigger a re-import of recordings from the newly-set work (the dual-work source_mb_work_id tagging). A "re-research" trigger could be wired in as a follow-up.

🤖 Generated with Claude Code

Add inline editors to the admin song detail page:

- MB Work ID and Secondary MB Work ID are both shown and editable.
  Entering an ID runs a MusicBrainz work lookup (cached via
  MusicBrainzSearcher) that surfaces the id, title, and composer/
  writer/lyricist credits; Save is gated on a successful lookup so
  an unverified ID cannot be persisted. Slots with a value get Clear.
- Alternate titles render under the song title as chips with an
  add/remove editor that saves to songs.alt_titles.

Backing endpoints:
- GET  /admin/musicbrainz/work/<id>/lookup
- POST /admin/songs/<id>/mb-id        (slot: primary|second)
- POST /admin/songs/<id>/alt-titles

CSRF is handled by the existing admin.js fetch wrapper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dprodger dprodger merged commit c738f87 into main Jun 14, 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