[scrobbles] Preserve note indentation on save so nested markdown lists render
Some checks failed
ci / build-and-deploy (push) Has been cancelled
ci / test (push) Has been cancelled

This commit is contained in:
2026-08-26 11:39:35 -04:00
parent 10617582a8
commit fd11e5e19e
3 changed files with 39 additions and 2 deletions

View File

@ -18,7 +18,7 @@ tasks, Todoist tasks, web pages I've read and trails I've hiked has turned out
to be sometimes cathartic and sometimes functional as I try to remember when I
did a thing.
* Backlog [0/30] :vrobbler:project:personal:
* Backlog [1/31] :vrobbler:project:personal:
** TODO [#C] Configure IMAP folder/start in user profile :imap:settings:
*** Description
@ -590,3 +590,8 @@ The Edit log form should have from top to bottom:
- People (which should be similar to the Bird widget on BirdLocation and allow setting per user score, win true/false, rank, new true/false, seat_ordrer)
- Expansion ids (which should a multi-select widget of expansions for this game)
- Location (which should be a drop down of BoardGameLocations for this user)
** DONE [#B] Fix bug in notes where nested markdown lists are not supported :notes:markdown:scrobbles:
:PROPERTIES:
:ID: f95db671-b27e-6f53-ceb0-ba61addf3a4b
:END:

View File

@ -621,6 +621,38 @@ def test_scrobble_detail_view_post_updates_log(client):
assert list(scrobble.log["notes"].values()) == ["Updated note"]
@pytest.mark.django_db
def test_scrobble_detail_view_post_preserves_nested_list_indentation(client):
user = get_user_model().objects.create_user(
username="testuser", email="test@example.com", password="testpass"
)
from lifeevents.models import LifeEvent
life_event = LifeEvent.objects.create(
title="Test Life Event", description="Test description"
)
scrobble = Scrobble.objects.create(
life_event=life_event,
media_type="LifeEvent",
user=user,
log={"description": "Test description"},
)
url = reverse("scrobbles:detail", kwargs={"pk": scrobble.id})
client.force_login(user)
response = client.post(
url,
{
"description": "Test description",
"notes": "- Item 1\n - Nested item\n- Item 2",
},
)
assert response.status_code == 302
scrobble.refresh_from_db()
assert scrobble.log["notes"] == "- Item 1\n - Nested item\n- Item 2"
@pytest.mark.skip("Need to refactor")
@pytest.mark.django_db
@patch("music.utils.lookup_artist_from_mb", return_value={})

View File

@ -98,7 +98,7 @@ def form_from_dataclass(dataclass):
def clean_notes(self):
notes_str = self.cleaned_data.get("notes", "")
return [line.strip() for line in notes_str.splitlines() if line.strip()]
return notes_str.strip()
form_cls.clean_notes = clean_notes
return form_cls