Ticket #494: 494.r12661.diff
File 494.r12661.diff, 6.1 KB (added by , 15 years ago) |
---|
-
django/forms/formsets.py
321 321 return mark_safe(u'\n'.join([unicode(self.management_form), forms])) 322 322 323 323 def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, 324 can_delete=False, max_num=0 ):324 can_delete=False, max_num=0, classes=None): 325 325 """Return a FormSet for the given form class.""" 326 326 attrs = {'form': form, 'extra': extra, 327 327 'can_order': can_order, 'can_delete': can_delete, 328 'max_num': max_num }328 'max_num': max_num, 'classes':classes or []} 329 329 return type(form.__name__ + 'FormSet', (formset,), attrs) 330 330 331 331 def all_valid(formsets): -
django/forms/models.py
643 643 super(BaseModelFormSet, self).add_fields(form, index) 644 644 645 645 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(), 646 formset=BaseModelFormSet, 646 formset=BaseModelFormSet, classes=None, 647 647 extra=1, can_delete=False, can_order=False, 648 648 max_num=0, fields=None, exclude=None): 649 649 """ … … 652 652 form = modelform_factory(model, form=form, fields=fields, exclude=exclude, 653 653 formfield_callback=formfield_callback) 654 654 FormSet = formset_factory(form, formset, extra=extra, max_num=max_num, 655 can_order=can_order, can_delete=can_delete) 655 can_order=can_order, can_delete=can_delete, 656 classes=classes or []) 656 657 FormSet.model = model 657 658 return FormSet 658 659 … … 794 795 795 796 def inlineformset_factory(parent_model, model, form=ModelForm, 796 797 formset=BaseInlineFormSet, fk_name=None, 797 fields=None, exclude=None, 798 fields=None, exclude=None, classes=None, 798 799 extra=3, can_order=False, can_delete=True, max_num=0, 799 800 formfield_callback=lambda f: f.formfield()): 800 801 """ … … 817 818 'fields': fields, 818 819 'exclude': exclude, 819 820 'max_num': max_num, 821 'classes': classes or [], 820 822 } 821 823 FormSet = modelformset_factory(model, **kwargs) 822 824 FormSet.fk = fk -
django/contrib/admin/options.py
1188 1188 verbose_name = None 1189 1189 verbose_name_plural = None 1190 1190 can_delete = True 1191 classes = [] 1191 1192 1192 1193 def __init__(self, parent_model, admin_site): 1193 1194 self.admin_site = admin_site … … 1204 1205 js = ['js/jquery.min.js', 'js/inlines.min.js'] 1205 1206 if self.prepopulated_fields: 1206 1207 js.append('js/urlify.js') 1208 if 'collapse' in self.classes: 1209 js.append('js/collapse.min.js') 1207 1210 if self.filter_vertical or self.filter_horizontal: 1208 1211 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 1209 1212 return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) … … 1234 1237 "extra": self.extra, 1235 1238 "max_num": self.max_num, 1236 1239 "can_delete": self.can_delete, 1240 "classes": self.classes, 1237 1241 } 1238 1242 defaults.update(kwargs) 1239 1243 return inlineformset_factory(self.parent_model, self.model, **defaults) -
django/contrib/admin/templates/admin/edit_inline/tabular.html
2 2 <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group"> 3 3 <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}"> 4 4 {{ inline_admin_formset.formset.management_form }} 5 <fieldset class="module ">5 <fieldset class="module {% for class in inline_admin_formset.formset.classes %} {{class}}{% endfor %}"> 6 6 <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2> 7 7 {{ inline_admin_formset.formset.non_form_errors }} 8 8 <table> -
django/contrib/contenttypes/generic.py
335 335 def generic_inlineformset_factory(model, form=ModelForm, 336 336 formset=BaseGenericInlineFormSet, 337 337 ct_field="content_type", fk_field="object_id", 338 fields=None, exclude=None, 338 fields=None, exclude=None, classes=None, 339 339 extra=3, can_order=False, can_delete=True, 340 340 max_num=0, 341 341 formfield_callback=lambda f: f.formfield()): … … 360 360 exclude = [ct_field.name, fk_field.name] 361 361 FormSet = modelformset_factory(model, form=form, 362 362 formfield_callback=formfield_callback, 363 formset=formset, 363 formset=formset, classes=classes or [], 364 364 extra=extra, can_delete=can_delete, can_order=can_order, 365 365 fields=fields, exclude=exclude, max_num=max_num) 366 366 FormSet.ct_field = ct_field … … 394 394 "can_order": False, 395 395 "fields": fields, 396 396 "max_num": self.max_num, 397 "exclude": exclude 397 "exclude": exclude, 398 "classes": classes, 398 399 } 399 400 return generic_inlineformset_factory(self.model, **defaults) 400 401