Skip to content

Commit

Permalink
Fix wrongly defined argument in get_attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Dec 10, 2024
1 parent 762b267 commit 3a2287e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
14 changes: 6 additions & 8 deletions bookmarks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,21 @@ class BookmarkCategory(models.Model):
def __str__(self):
return f"{self.name}"

def get_attribution(self, sound_qs):
def get_attribution(self, sound_qs=None):
#If no queryset of sounds is provided, take it from the bookmark category
if(sound_qs):
sounds_list=sound_qs
else:
if sound_qs is None:
bookmarked_sounds = Bookmark.objects.filter(category_id=self.id).values("sound_id")
sounds_list = Sound.objects.filter(id__in=bookmarked_sounds, processing_state="OK", moderation_state="OK").select_related('user','license')
sound_qs = Sound.objects.filter(id__in=bookmarked_sounds, processing_state="OK", moderation_state="OK").select_related('user','license')

users = User.objects.filter(sounds__in=sounds_list).distinct()
users = User.objects.filter(sounds__in=sound_qs).distinct()
# Generate text file with license info
licenses = License.objects.filter(sound__id__in = sounds_list).distinct()
licenses = License.objects.filter(sound__id__in=sound_qs).distinct()
attribution = render_to_string(("sounds/multiple_sounds_attribution.txt"),
dict(type="Bookmark Category",
users=users,
object=self,
licenses=licenses,
sound_list=sounds_list))
sound_list=sound_qs))
return attribution


Expand Down
12 changes: 5 additions & 7 deletions sounds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,23 +1788,21 @@ def invalidate_template_caches(self):
invalidate_template_cache("bw_display_pack", self.id, player_size)
invalidate_template_cache("bw_pack_stats", self.id)

def get_attribution(self, sound_qs):
def get_attribution(self, sound_qs=None):
#If no queryset of sounds is provided, take it from the pack
if(sound_qs):
sounds_list = sound_qs
else:
sounds_list = self.sounds.filter(processing_state="OK",
if sound_qs is None:
sound_qs = self.sounds.filter(processing_state="OK",
moderation_state="OK").select_related('user', 'license')

users = User.objects.filter(sounds__in=sounds_list).distinct()
users = User.objects.filter(sounds__in=sound_qs).distinct()
# Generate text file with license info
licenses = License.objects.filter(sound__pack=self).distinct()
attribution = render_to_string("sounds/multiple_sounds_attribution.txt",
dict(type="Pack",
users=users,
object=self,
licenses=licenses,
sound_list=sounds_list))
sound_list=sound_qs))
return attribution

@property
Expand Down

0 comments on commit 3a2287e

Please sign in to comment.