diff --git a/PROJECT.org b/PROJECT.org index ac38398..a2e1b65 100644 --- a/PROJECT.org +++ b/PROJECT.org @@ -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: diff --git a/tests/scrobbles_tests/test_views.py b/tests/scrobbles_tests/test_views.py index 6aaa576..9a57a20 100644 --- a/tests/scrobbles_tests/test_views.py +++ b/tests/scrobbles_tests/test_views.py @@ -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={}) diff --git a/vrobbler/apps/scrobbles/forms.py b/vrobbler/apps/scrobbles/forms.py index 614c456..9735459 100644 --- a/vrobbler/apps/scrobbles/forms.py +++ b/vrobbler/apps/scrobbles/forms.py @@ -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