1 from django.forms.widgets import Textarea
2 from django.utils import simplejson as json
4 __all__ = ('EmbedWidget',)
6 class EmbedWidget(Textarea):
7 """A form widget with the HTML class embedding and an embedded list of content-types."""
8 def __init__(self, attrs=None):
9 from philo.models import value_content_type_limiter
11 content_types = value_content_type_limiter.classes
14 for content_type in content_types:
15 data.append({'app_label': content_type._meta.app_label, 'object_name': content_type._meta.object_name.lower(), 'verbose_name': unicode(content_type._meta.verbose_name)})
17 json_ = json.dumps(data)
19 default_attrs = {'class': 'embedding vLargeTextField', 'data-content-types': json_ }
22 default_attrs.update(attrs)
24 super(EmbedWidget, self).__init__(default_attrs)
28 'all': ('philo/css/EmbedWidget.css',),
30 js = ('philo/js/EmbedWidget.js',)