Ticket #494: 494.4.patch

File 494.4.patch, 7.2 KB (added by Antonis Christofides, 16 years ago)

Patch that fixes spotted errors

  • django/forms/formsets.py

     
    273273        return mark_safe(u'\n'.join([unicode(self.management_form), forms]))
    274274
    275275def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
    276                     can_delete=False, max_num=0):
     276                    can_delete=False, max_num=0, classes=[]):
    277277    """Return a FormSet for the given form class."""
    278     attrs = {'form': form, 'extra': extra,
     278    attrs = {'form': form, 'extra': extra, 'classes': classes,
    279279             'can_order': can_order, 'can_delete': can_delete,
    280280             'max_num': max_num}
    281281    return type(form.__name__ + 'FormSet', (formset,), attrs)
  • django/forms/models.py

     
    435435        super(BaseModelFormSet, self).add_fields(form, index)
    436436
    437437def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(),
    438                          formset=BaseModelFormSet,
     438                         formset=BaseModelFormSet, classes=[],
    439439                         extra=1, can_delete=False, can_order=False,
    440440                         max_num=0, fields=None, exclude=None):
    441441    """
     
    444444    form = modelform_factory(model, form=form, fields=fields, exclude=exclude,
    445445                             formfield_callback=formfield_callback)
    446446    FormSet = formset_factory(form, formset, extra=extra, max_num=max_num,
    447                               can_order=can_order, can_delete=can_delete)
     447                              can_order=can_order, can_delete=can_delete,
     448                              classes=classes)
    448449    FormSet.model = model
    449450    return FormSet
    450451
     
    530531
    531532def inlineformset_factory(parent_model, model, form=ModelForm,
    532533                          formset=BaseInlineFormSet, fk_name=None,
    533                           fields=None, exclude=None,
     534                          fields=None, exclude=None, classes=[],
    534535                          extra=3, can_order=False, can_delete=True, max_num=0,
    535536                          formfield_callback=lambda f: f.formfield()):
    536537    """
     
    560561        'fields': fields,
    561562        'exclude': exclude,
    562563        'max_num': max_num,
     564        'classes': classes,
    563565    }
    564566    FormSet = modelformset_factory(model, **kwargs)
    565567    FormSet.fk = fk
  • django/contrib/admin/options.py

     
    751751    template = None
    752752    verbose_name = None
    753753    verbose_name_plural = None
     754    classes = []
    754755
    755756    def __init__(self, parent_model, admin_site):
    756757        self.admin_site = admin_site
     
    767768        js = []
    768769        if self.prepopulated_fields:
    769770            js.append('js/urlify.js')
     771        if 'collapse' in self.classes:
     772            js.append('js/admin/CollapsedFieldsets.js')
    770773        if self.filter_vertical or self.filter_horizontal:
    771774            js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js'])
    772775        return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
     
    791794            "formfield_callback": self.formfield_for_dbfield,
    792795            "extra": self.extra,
    793796            "max_num": self.max_num,
     797            "classes": self.classes,
    794798        }
    795799        defaults.update(kwargs)
    796800        return inlineformset_factory(self.parent_model, self.model, **defaults)
  • django/contrib/admin/templates/admin/edit_inline/stacked.html

     
    11{% load i18n %}
    22<div class="inline-group">
     3<fieldset class="module {% for class in inline_admin_formset.formset.classes %}{{class}}{% endfor %}">
    34  <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
    45{{ inline_admin_formset.formset.management_form }}
    56{{ inline_admin_formset.formset.non_form_errors }}
     
    2526{# <ul class="tools"> #}
    2627{#   <li><a class="add" href="">Add another {{ inline_admin_formset.opts.verbose_name|title }}</a></li> #}
    2728{# </ul> #}
     29</fieldset>
    2830</div>
  • django/contrib/admin/templates/admin/edit_inline/tabular.html

     
    22<div class="inline-group">
    33  <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
    44{{ inline_admin_formset.formset.management_form }}
    5 <fieldset class="module">
     5<fieldset class="module {% for class in inline_admin_formset.formset.classes %}{{class}}{% endfor %}">
    66   <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
    77   {{ inline_admin_formset.formset.non_form_errors }}
    88   <table>
  • django/contrib/contenttypes/generic.py

     
    326326def generic_inlineformset_factory(model, form=ModelForm,
    327327                                  formset=BaseGenericInlineFormSet,
    328328                                  ct_field="content_type", fk_field="object_id",
    329                                   fields=None, exclude=None,
     329                                  fields=None, exclude=None, classes=[],
    330330                                  extra=3, can_order=False, can_delete=True,
    331331                                  max_num=0,
    332332                                  formfield_callback=lambda f: f.formfield()):
     
    350350        exclude = [ct_field.name, fk_field.name]
    351351    FormSet = modelformset_factory(model, form=form,
    352352                                   formfield_callback=formfield_callback,
    353                                    formset=formset,
     353                                   formset=formset, classes=classes,
    354354                                   extra=extra, can_delete=can_delete, can_order=can_order,
    355355                                   fields=fields, exclude=exclude, max_num=max_num)
    356356    FormSet.ct_field = ct_field
  • docs/ref/contrib/admin.txt

     
    776776An override to the ``verbose_name_plural`` found in the model's inner ``Meta``
    777777class.
    778778
     779``classes``
     780~~~~~~~~~~~
     781
     782.. versionadded:: development
     783
     784A list containing extra CSS classes to apply to the inline.
     785
     786Example::
     787
     788    class BookInline(admin.TabularInline):
     789        classes = ['collapse', 'extrapretty']
     790
     791A useful class is ``collapse``, which will cause the inline to be initially
     792collapsed.
     793
    779794Working with a model with two or more foreign keys to the same parent model
    780795---------------------------------------------------------------------------
    781796
Back to Top