[scrobbles] Fix edit log ordering of people
This commit is contained in:
@ -5,6 +5,7 @@ from typing import Optional
|
||||
from dataclass_wizard import JSONWizard
|
||||
from django import forms
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Count
|
||||
from people.models import Person
|
||||
from scrobbles.forms import form_from_dataclass
|
||||
|
||||
@ -60,9 +61,7 @@ class BaseLogData(JSONDataclass):
|
||||
note_str = self.notes.encode("utf-8").decode("unicode_escape")
|
||||
if isinstance(self.notes, list):
|
||||
note_str = (
|
||||
"\n".join(self.notes)
|
||||
.encode("utf-8")
|
||||
.decode("unicode_escape")
|
||||
"\n".join(self.notes).encode("utf-8").decode("unicode_escape")
|
||||
)
|
||||
return note_str
|
||||
|
||||
@ -82,10 +81,7 @@ class WithPeopleLogData(JSONDataclass):
|
||||
|
||||
if not self.with_people_ids:
|
||||
return []
|
||||
return [
|
||||
Person.objects.filter(id=pid).first()
|
||||
for pid in self.with_people_ids
|
||||
]
|
||||
return [Person.objects.filter(id=pid).first() for pid in self.with_people_ids]
|
||||
|
||||
@classmethod
|
||||
def override_fields(cls) -> dict:
|
||||
@ -96,7 +92,9 @@ class WithPeopleLogData(JSONDataclass):
|
||||
fields.update(base_fields)
|
||||
custom_fields = {
|
||||
"with_people_ids": forms.ModelMultipleChoiceField(
|
||||
queryset=Person.objects.all(),
|
||||
queryset=Person.objects.annotate(
|
||||
scrobble_count=Count("scrobble_associations")
|
||||
).order_by("-scrobble_count"),
|
||||
required=False,
|
||||
widget=forms.SelectMultiple(attrs={"size": 10}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user