]> git.0d.be Git - django-panik-combo.git/blobdiff - panikombo/models.py
add option to limit sounds to a given format
[django-panik-combo.git] / panikombo / models.py
index 26a8e305d63a0358e82260a7f9cdf0d4cb2a1d0b..6ad7c8f57132a0c06be51dcd8ea54ec83785e167 100644 (file)
@@ -229,6 +229,8 @@ class SoundsCell(CellBase):
     include_search_input = models.BooleanField(_('Include search input'), default=True)
     include_fragments = models.BooleanField(_('Include fragments'), default=True)
     limit_to_focus = models.BooleanField(_('Limit to focused elements'), default=False)
+    sound_format = models.ForeignKey('emissions.Format',
+            verbose_name=_('Limit to format'), null=True, blank=True)
     count = models.PositiveSmallIntegerField(_('Count'), default=20)
     sort_order = models.CharField(_('Sort order'), default='-creation_timestamp',
             max_length=30,
@@ -251,6 +253,8 @@ class SoundsCell(CellBase):
             soundfiles = soundfiles.filter(fragment=False)
         if self.limit_to_focus:
             soundfiles = soundfiles.filter(got_focus__isnull=False)
+        if self.sound_format:
+            soundfiles = soundfiles.filter(format_id=self.sound_format_id)
         soundfiles = soundfiles.select_related().extra(
                     select={'first_diffusion': 'emissions_diffusion.datetime', },
                     select_params=(False, True),