+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
-from .models import SoundCell, EpisodeCell, EpisodeAutoSelectionCell
+from .models import (SoundCell, EpisodeCell, EpisodeAutoSelectionCell,
+ NewsItemAutoSelectionCell, Topik)
from .views import soundfiles, episodes
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):
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):
class EpisodeAutoSelectionCellForm(forms.ModelForm):
class Meta:
model = EpisodeAutoSelectionCell
- fields = ('title', 'tags', 'category')
+ fields = ('title', 'tags', 'and_tags', 'category', 'period')
+ widgets = {'tags': TagWidget()}
+
+
+class NewsItemAutoSelectionCellForm(forms.ModelForm):
+ class Meta:
+ model = NewsItemAutoSelectionCell
+ fields = ('title', 'tags', 'and_tags', 'category', 'future')
widgets = {'tags': TagWidget()}
+
+
+class TopikEditForm(forms.ModelForm):
+ class Meta:
+ model = Topik
+ fields = ('image',)