]> git.0d.be Git - django-panik-combo.git/blobdiff - panikombo/forms.py
add additional "and_tags" field to auto selection, for ANDing criterias
[django-panik-combo.git] / panikombo / forms.py
index 01fb013a9b0520dbf1ace95c7f2998a5c5e303af..8cb67c53d02aa3ab4036b6678dcaee6793a400f1 100644 (file)
@@ -1,5 +1,7 @@
+import json
+
 from django import forms
-from django_select2.widgets import HeavySelect2Widget, convert_to_js_string_arr
+from django_select2.widgets import HeavySelect2Widget
 from taggit.forms import TagWidget
 
 from emissions.models import SoundFile, Episode
@@ -16,7 +18,7 @@ class SoundFileWidget(HeavySelect2Widget):
                     soundfile.episode.title,
                     soundfile.title or soundfile.id)
         texts = [fmt(soundfile) for soundfile in queryset.select_related()]
-        return convert_to_js_string_arr(texts)
+        return json.dumps(texts)
 
 
 class SoundCellForm(forms.ModelForm):
@@ -35,7 +37,7 @@ class EpisodeWidget(HeavySelect2Widget):
         def fmt(episode):
             return '%s - %s' % (episode.emission.title, episode.title)
         texts = [fmt(episode) for episode in queryset.select_related()]
-        return convert_to_js_string_arr(texts)
+        return json.dumps(texts)
 
 
 class EpisodeCellForm(forms.ModelForm):
@@ -51,14 +53,14 @@ class EpisodeCellForm(forms.ModelForm):
 class EpisodeAutoSelectionCellForm(forms.ModelForm):
     class Meta:
         model = EpisodeAutoSelectionCell
-        fields = ('title', 'tags', 'category', 'period')
+        fields = ('title', 'tags', 'and_tags', 'category', 'period')
         widgets = {'tags': TagWidget()}
 
 
 class NewsItemAutoSelectionCellForm(forms.ModelForm):
     class Meta:
         model = NewsItemAutoSelectionCell
-        fields = ('title', 'tags', 'category', 'future')
+        fields = ('title', 'tags', 'and_tags', 'category', 'future')
         widgets = {'tags': TagWidget()}