Skip to content

Commit

Permalink
fix: Also apply filter_by filter on section filter in `section_from_a…
Browse files Browse the repository at this point in the history
…ny_song` session model method
  • Loading branch information
drikusroor committed Jun 12, 2024
1 parent f8b0a9c commit 9adcfcf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/session/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ def section_from_any_song(self, filter_by={}):
To ensure appropriate IP restrictions, most rules should use this
method instead of operating on the playlist directly.
"""

pks = self.filter_songs(filter_by)
if pks:
# Return a random section
sections = self.playlist.section_set.filter(song_id=random.choice(pks))
sections = self.playlist.section_set.filter(
song_id=random.choice(pks)
).filter(
**filter_by
)
return random.choice(sections)

def all_sections(self, filter_by={}):
Expand Down

0 comments on commit 9adcfcf

Please sign in to comment.