[scrobbles] Big update for notes in tasks and boardgames
This commit is contained in:
@ -38,6 +38,18 @@ class TaskLogData(BaseLogData):
|
||||
"todoist_project_id",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def override_fields(cls) -> dict:
|
||||
from scrobbles.forms import NotesDictField
|
||||
|
||||
fields = {}
|
||||
for base in cls.mro()[1:]:
|
||||
if hasattr(base, "override_fields"):
|
||||
base_fields = base.override_fields()
|
||||
fields.update(base_fields)
|
||||
fields["notes"] = NotesDictField(required=False)
|
||||
return fields
|
||||
|
||||
def notes_as_str(self, separator: str = " | ") -> str:
|
||||
"""Return formatted notes with line breaks and no keys"""
|
||||
labels_str = ""
|
||||
@ -47,13 +59,14 @@ class TaskLogData(BaseLogData):
|
||||
lines = []
|
||||
if self.notes:
|
||||
notes = self.notes
|
||||
if isinstance(notes, dict):
|
||||
notes = [{k: v} for k, v in notes.items()]
|
||||
if isinstance(notes, str):
|
||||
notes = [notes]
|
||||
|
||||
for note in notes:
|
||||
if isinstance(note, dict):
|
||||
timestamp, note_text = next(iter(note.items()))
|
||||
# Flatten newlines and clean whitespace
|
||||
note_text = " ".join(note_text.strip().split())
|
||||
lines.append(f"{timestamp}: {note_text}")
|
||||
if isinstance(note, list):
|
||||
@ -67,6 +80,8 @@ class TaskLogData(BaseLogData):
|
||||
return ""
|
||||
|
||||
notes = self.notes
|
||||
if isinstance(notes, dict):
|
||||
notes = [{k: v} for k, v in notes.items()]
|
||||
if isinstance(notes, str):
|
||||
notes = [notes]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user