X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..67552e19bc548b78c18967e97f0c0328074a3576:/src/newtagging/admin.py diff --git a/src/newtagging/admin.py b/src/newtagging/admin.py index 57a76d5d4..569982dde 100644 --- a/src/newtagging/admin.py +++ b/src/newtagging/admin.py @@ -14,7 +14,7 @@ class FilteredSelectMultiple(forms.SelectMultiple): """ def _media(self): from django.conf import settings - js = ['js/SelectBox.js' , 'js/SelectFilter2.js'] + js = ['js/SelectBox.js', 'js/SelectFilter2.js'] return forms.Media(js=['%sadmin/%s' % (settings.STATIC_URL, url) for url in js]) media = property(_media) @@ -25,17 +25,22 @@ class FilteredSelectMultiple(forms.SelectMultiple): def render(self, name, value, attrs=None, choices=()): from django.conf import settings - output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)] - output.append(u'\n' % ( + name, self.verbose_name.replace('"', '\\"'), + int(self.is_stacked), settings.STATIC_URL + "admin/") + ] # TODO: "id_" is hard-coded here. This should instead use the correct # API to determine the ID dynamically. - output.append(u'SelectFilter.init("id_%s", "%s", %s, "%s"); });\n' % \ - (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.STATIC_URL + "admin/")) return mark_safe(u''.join(output)) class TaggableModelForm(forms.ModelForm): - tags = forms.MultipleChoiceField(label=_('tags').capitalize(), required=False, widget=FilteredSelectMultiple(_('tags'), False)) + tags = forms.MultipleChoiceField( + label=_('tags').capitalize(), required=False, + widget=FilteredSelectMultiple(_('tags'), is_stacked=False)) def __init__(self, *args, **kwargs): if 'instance' in kwargs: @@ -64,4 +69,3 @@ class TaggableModelAdmin(admin.ModelAdmin): form = super(TaggableModelAdmin, self).get_form(request, obj) form.tag_model = self.tag_model return form -