Ticket #494: 494.7.patch
File 494.7.patch, 8.8 KB (added by , 15 years ago) |
---|
-
django/django/forms/formsets.py
302 302 return mark_safe(u'\n'.join([unicode(self.management_form), forms])) 303 303 304 304 def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, 305 can_delete=False, max_num=0 ):305 can_delete=False, max_num=0, classes=[]): 306 306 """Return a FormSet for the given form class.""" 307 attrs = {'form': form, 'extra': extra, 307 attrs = {'form': form, 'extra': extra, 'classes': classes, 308 308 'can_order': can_order, 'can_delete': can_delete, 309 309 'max_num': max_num} 310 310 return type(form.__name__ + 'FormSet', (formset,), attrs) -
django/django/forms/models.py
675 675 super(BaseModelFormSet, self).add_fields(form, index) 676 676 677 677 def modelformset_factory(model, form=ModelForm, formfield_callback=lambda f: f.formfield(), 678 formset=BaseModelFormSet, 678 formset=BaseModelFormSet, classes=[], 679 679 extra=1, can_delete=False, can_order=False, 680 680 max_num=0, fields=None, exclude=None): 681 681 """ … … 684 684 form = modelform_factory(model, form=form, fields=fields, exclude=exclude, 685 685 formfield_callback=formfield_callback) 686 686 FormSet = formset_factory(form, formset, extra=extra, max_num=max_num, 687 can_order=can_order, can_delete=can_delete) 687 can_order=can_order, can_delete=can_delete, 688 classes=classes) 688 689 FormSet.model = model 689 690 return FormSet 690 691 … … 811 812 812 813 def inlineformset_factory(parent_model, model, form=ModelForm, 813 814 formset=BaseInlineFormSet, fk_name=None, 814 fields=None, exclude=None, 815 fields=None, exclude=None, classes=[], 815 816 extra=3, can_order=False, can_delete=True, max_num=0, 816 817 formfield_callback=lambda f: f.formfield()): 817 818 """ … … 834 835 'fields': fields, 835 836 'exclude': exclude, 836 837 'max_num': max_num, 838 'classes': classes, 837 839 } 838 840 FormSet = modelformset_factory(model, **kwargs) 839 841 FormSet.fk = fk -
django/django/contrib/admin/media/js/admin/CollapsedFieldsets.js
11 11 } 12 12 13 13 var CollapsedFieldsets = { 14 collapse_re: /\bcollapse\b/ , // Class of fieldsets that should be dealt with.15 collapsed_re: /\bcollapsed\b/ , // Class that fieldsets get when they're hidden.14 collapse_re: /\bcollapse\b/g, // Class of fieldsets that should be dealt with. 15 collapsed_re: /\bcollapsed\b/g, // Class that fieldsets get when they're hidden. 16 16 collapsed_class: 'collapsed', 17 17 init: function() { 18 18 var fieldsets = document.getElementsByTagName('fieldset'); -
django/django/contrib/admin/options.py
1109 1109 template = None 1110 1110 verbose_name = None 1111 1111 verbose_name_plural = None 1112 classes = [] 1112 1113 1113 1114 def __init__(self, parent_model, admin_site): 1114 1115 self.admin_site = admin_site … … 1125 1126 js = [] 1126 1127 if self.prepopulated_fields: 1127 1128 js.append('js/urlify.js') 1129 if 'collapse' in self.classes: 1130 js.append('js/admin/CollapsedFieldsets.js') 1128 1131 if self.filter_vertical or self.filter_horizontal: 1129 1132 js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 1130 1133 return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) … … 1151 1154 "formfield_callback": curry(self.formfield_for_dbfield, request=request), 1152 1155 "extra": self.extra, 1153 1156 "max_num": self.max_num, 1157 "classes": self.classes, 1154 1158 } 1155 1159 defaults.update(kwargs) 1156 1160 return inlineformset_factory(self.parent_model, self.model, **defaults) -
django/django/contrib/admin/templates/admin/edit_inline/stacked.html
1 1 {% load i18n %} 2 2 <div class="inline-group"> 3 <fieldset class="module {% for class in inline_admin_formset.formset.classes %}{{class}}{% endfor %}"> 3 4 <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2> 4 5 {{ inline_admin_formset.formset.management_form }} 5 6 {{ inline_admin_formset.formset.non_form_errors }} … … 25 26 {# <ul class="tools"> #} 26 27 {# <li><a class="add" href="">Add another {{ inline_admin_formset.opts.verbose_name|title }}</a></li> #} 27 28 {# </ul> #} 29 </fieldset> 28 30 </div> -
django/django/contrib/admin/templates/admin/edit_inline/tabular.html
2 2 <div class="inline-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/django/contrib/contenttypes/generic.py
337 337 def generic_inlineformset_factory(model, form=ModelForm, 338 338 formset=BaseGenericInlineFormSet, 339 339 ct_field="content_type", fk_field="object_id", 340 fields=None, exclude=None, 340 fields=None, exclude=None, classes=[], 341 341 extra=3, can_order=False, can_delete=True, 342 342 max_num=0, 343 343 formfield_callback=lambda f: f.formfield()): … … 362 362 exclude = [ct_field.name, fk_field.name] 363 363 FormSet = modelformset_factory(model, form=form, 364 364 formfield_callback=formfield_callback, 365 formset=formset, 365 formset=formset, classes=classes, 366 366 extra=extra, can_delete=can_delete, can_order=can_order, 367 367 fields=fields, exclude=exclude, max_num=max_num) 368 368 FormSet.ct_field = ct_field … … 390 390 "can_order": False, 391 391 "fields": fields, 392 392 "max_num": self.max_num, 393 "exclude": self.exclude 393 "exclude": self.exclude, 394 "classes": self.classes, 394 395 } 395 396 return generic_inlineformset_factory(self.model, **defaults) 396 397 -
django/docs/ref/contrib/admin/index.txt
915 915 An override to the ``verbose_name_plural`` found in the model's inner ``Meta`` 916 916 class. 917 917 918 ``classes`` 919 ~~~~~~~~~~~ 920 921 .. versionadded:: development 922 923 A list containing extra CSS classes to apply to the inline. 924 925 Example:: 926 927 class BookInline(admin.TabularInline): 928 classes = ['collapse', 'extrapretty'] 929 930 A useful class is ``collapse``, which will cause the inline to be initially 931 collapsed. 932 918 933 Working with a model with two or more foreign keys to the same parent model 919 934 ---------------------------------------------------------------------------