X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/bf382c2dc051c451711c65b1967aecc65ede74e5..f314a8ddceb543e2bb4711d50bdd2060452689b1:/admin/widgets.py?ds=inline
diff --git a/admin/widgets.py b/admin/widgets.py
index f53c5b7..7a47c63 100644
--- a/admin/widgets.py
+++ b/admin/widgets.py
@@ -1,9 +1,10 @@
from django import forms
from django.conf import settings
+from django.contrib.admin.widgets import FilteredSelectMultiple
from django.utils.translation import ugettext as _
-from django.utils.html import escape
-from django.utils.text import truncate_words
from django.utils.safestring import mark_safe
+from django.utils.text import truncate_words
+from django.utils.html import escape
class ModelLookupWidget(forms.TextInput):
@@ -30,4 +31,35 @@ class ModelLookupWidget(forms.TextInput):
output += ' %s' % escape(truncate_words(value_object, 14))
except value_class.DoesNotExist:
pass
- return mark_safe(output)
\ No newline at end of file
+ return mark_safe(output)
+
+
+class TagFilteredSelectMultiple(FilteredSelectMultiple):
+ """
+ A SelectMultiple with a JavaScript filter interface.
+
+ Note that the resulting JavaScript assumes that the jsi18n
+ catalog has been loaded in the page
+ """
+ class Media:
+ js = (settings.ADMIN_MEDIA_PREFIX + "js/core.js",
+ settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js",
+ settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js")
+
+ if 'staticmedia' in settings.INSTALLED_APPS:
+ import staticmedia
+ js += (staticmedia.url('admin/js/TagCreation.js'),)
+ else:
+ js += (settings.ADMIN_MEDIA_PREFIX + "js/TagCreation.js",)
+
+ def render(self, name, value, attrs=None, choices=()):
+ if attrs is None: attrs = {}
+ attrs['class'] = 'selectfilter'
+ if self.is_stacked: attrs['class'] += 'stacked'
+ output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]
+ output.append(u'\n' % \
+ (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX, name))
+ return mark_safe(u''.join(output))
\ No newline at end of file