# Path: djam/widgets.py
# class AddWrapper(Widget):
#     template_name = 'floppyforms/addwrapper.html'
# 
#     def __init__(self, widget, riff):
#         self.widget = widget
#         self.riff = riff
#         super(AddWrapper, self).__init__()
# 
#     def get_context(self, name, value, attrs=None, **kwargs):
#         attrs = attrs or {}
#         context = {
#             'rendered': self.widget.render(name, value, attrs, **kwargs),
#             'riff': self.riff,
#         }
#         context['attrs'] = self.build_attrs(attrs)
#         return context
# 
#     def value_from_datadict(self, data, files, name):
#         return self.widget.value_from_datadict(data, files, name)
# 
#     def _has_changed(self, initial, data):
#         return self.widget._has_changed(initial, data)
# 
#     def render(self, name, value, attrs=None, **kwargs):
#         context = self.get_context(name, value, attrs, **kwargs)
#         return loader.render_to_string(
#             self.template_name,
#             dictionary=context,
#             context_instance=None)


from django.contrib.admin.util import flatten_fieldsets
from django.db import models
from django import forms
from django.forms.models import modelform_factory
from django.utils.cache import add_never_cache_headers
from django.utils.translation import ugettext as _, string_concat
from django.views import generic
from djam.widgets import AddWrapper
import floppyforms
        mod, cls_name = widget.__module__, widget.__class__.__name__
        if mod == 'django.forms.widgets' and 'widget' not in kwargs:
            kwargs['widget'] = getattr(floppyforms, cls_name)
            rebuild = True
        return rebuild, kwargs

    def _post_formfield(self, field, db_field):
        field.widget.attrs['data-required'] = int(field.required)
        if issubclass(db_field.__class__, models.ManyToManyField):
            msg = _('Hold down "Control", or "Command" on a Mac, to select '
                    'more than one.')
            msg = unicode(string_concat(' ', msg))
            if field.help_text.endswith(msg):
                field.help_text = field.help_text[:-len(msg)]
        if (isinstance(field, forms.ChoiceField) and
                hasattr(field, 'queryset')):
            model = field.queryset.model
            if isinstance(field, forms.MultipleChoiceField):
                msg = string_concat(_("Choose some "),
                                    model._meta.verbose_name_plural,
                                    "...")
            else:
                msg = string_concat(_("Choose a "),
                                    model._meta.verbose_name,
                                    "...")
            field.widget.attrs['data-placeholder'] = msg

            for riff in self.riff.base_riff.riffs:
                if getattr(riff, 'model', None) == model:
                    if riff.has_add_permission(self.request):

# Path: djam/widgets.py
# class AddWrapper(Widget):
#     template_name = 'floppyforms/addwrapper.html'
# 
#     def __init__(self, widget, riff):
#         self.widget = widget
#         self.riff = riff
#         super(AddWrapper, self).__init__()
# 
#     def get_context(self, name, value, attrs=None, **kwargs):
#         attrs = attrs or {}
#         context = {
#             'rendered': self.widget.render(name, value, attrs, **kwargs),
#             'riff': self.riff,
#         }
#         context['attrs'] = self.build_attrs(attrs)
#         return context
# 
#     def value_from_datadict(self, data, files, name):
#         return self.widget.value_from_datadict(data, files, name)
# 
#     def _has_changed(self, initial, data):
#         return self.widget._has_changed(initial, data)
# 
#     def render(self, name, value, attrs=None, **kwargs):
#         context = self.get_context(name, value, attrs, **kwargs)
#         return loader.render_to_string(
#             self.template_name,
#             dictionary=context,
#             context_instance=None)


# Path: djam/views/generic.py
from django.contrib.admin.util import flatten_fieldsets
from django.db import models
from django import forms
from django.forms.models import modelform_factory
from django.utils.cache import add_never_cache_headers
from django.utils.translation import ugettext as _, string_concat
from django.views import generic
from djam.widgets import AddWrapper
import floppyforms

        mod, cls_name = widget.__module__, widget.__class__.__name__
        if mod == 'django.forms.widgets' and 'widget' not in kwargs:
            kwargs['widget'] = getattr(floppyforms, cls_name)
            rebuild = True
        return rebuild, kwargs

    def _post_formfield(self, field, db_field):
        field.widget.attrs['data-required'] = int(field.required)
        if issubclass(db_field.__class__, models.ManyToManyField):
            msg = _('Hold down "Control", or "Command" on a Mac, to select '
                    'more than one.')
            msg = unicode(string_concat(' ', msg))
            if field.help_text.endswith(msg):
                field.help_text = field.help_text[:-len(msg)]
        if (isinstance(field, forms.ChoiceField) and
                hasattr(field, 'queryset')):
            model = field.queryset.model
            if isinstance(field, forms.MultipleChoiceField):
                msg = string_concat(_("Choose some "),
                                    model._meta.verbose_name_plural,
                                    "...")
            else:
                msg = string_concat(_("Choose a "),
                                    model._meta.verbose_name,
                                    "...")
            field.widget.attrs['data-placeholder'] = msg

            for riff in self.riff.base_riff.riffs:
                if getattr(riff, 'model', None) == model:
                    if riff.has_add_permission(self.request):

                        field.widget = AddWrapper(field.widget, riff)