Ticket #10607: inline-fieldsets.diff
File inline-fieldsets.diff, 3.5 KB (added by , 16 years ago) |
---|
-
options.py
760 760 formset = FormSet(instance=self.model(), prefix=prefix) 761 761 formsets.append(formset) 762 762 763 adminForm = helpers.AdminForm(form, list(self.get_fieldsets(request)), self.prepopulated_fields )763 adminForm = helpers.AdminForm(form, list(self.get_fieldsets(request)), self.prepopulated_fields, request) 764 764 media = self.media + adminForm.media 765 765 766 766 inline_admin_formsets = [] 767 767 for inline, formset in zip(self.inline_instances, formsets): 768 fieldsets = list(inline.get_fieldsets(request)) 769 inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, fieldsets) 768 inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, request) 770 769 inline_admin_formsets.append(inline_admin_formset) 771 770 media = media + inline_admin_formset.media 772 771 … … 853 852 854 853 inline_admin_formsets = [] 855 854 for inline, formset in zip(self.inline_instances, formsets): 856 fieldsets = list(inline.get_fieldsets(request, obj)) 857 inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, fieldsets) 855 inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, request) 858 856 inline_admin_formsets.append(inline_admin_formset) 859 857 media = media + inline_admin_formset.media 860 858 -
helpers.py
104 104 """ 105 105 A wrapper around an inline formset for use in the admin system. 106 106 """ 107 def __init__(self, inline, formset, fieldsets):107 def __init__(self, inline, formset, request): 108 108 self.opts = inline 109 109 self.formset = formset 110 self. fieldsets = fieldsets110 self.request = request 111 111 112 112 def __iter__(self): 113 113 for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()): 114 yield InlineAdminForm(self.formset, form, self. fieldsets, self.opts.prepopulated_fields, original)114 yield InlineAdminForm(self.formset, form, self.opts.prepopulated_fields, original, self.request, self.opts) 115 115 for form in self.formset.extra_forms: 116 yield InlineAdminForm(self.formset, form, self. fieldsets, self.opts.prepopulated_fields, None)116 yield InlineAdminForm(self.formset, form, self.opts.prepopulated_fields, None, self.request, self.opts) 117 117 118 118 def fields(self): 119 119 fk = getattr(self.formset, "fk", None) … … 133 133 """ 134 134 A wrapper around an inline form for use in the admin system. 135 135 """ 136 def __init__(self, formset, form, fieldsets, prepopulated_fields, original):136 def __init__(self, formset, form, prepopulated_fields, original, request, opts): 137 137 self.formset = formset 138 138 self.original = original 139 self.request = request 139 140 if original is not None: 140 141 self.original.content_type_id = ContentType.objects.get_for_model(original).pk 141 142 self.show_url = original and hasattr(original, 'get_absolute_url') 142 super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields)143 super(InlineAdminForm, self).__init__(form, opts.get_fieldsets(request, original), prepopulated_fields) 143 144 144 145 def __iter__(self): 145 146 for name, options in self.fieldsets: