Ticket #10607: inline-fieldsets.diff

File inline-fieldsets.diff, 3.5 KB (added by juriejan, 16 years ago)

inline form fieldsets retrieved from 'get_fieldsets' method

  • options.py

     
    760760                formset = FormSet(instance=self.model(), prefix=prefix)
    761761                formsets.append(formset)
    762762
    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)
    764764        media = self.media + adminForm.media
    765765
    766766        inline_admin_formsets = []
    767767        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)
    770769            inline_admin_formsets.append(inline_admin_formset)
    771770            media = media + inline_admin_formset.media
    772771
     
    853852
    854853        inline_admin_formsets = []
    855854        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)
    858856            inline_admin_formsets.append(inline_admin_formset)
    859857            media = media + inline_admin_formset.media
    860858
  • helpers.py

     
    104104    """
    105105    A wrapper around an inline formset for use in the admin system.
    106106    """
    107     def __init__(self, inline, formset, fieldsets):
     107    def __init__(self, inline, formset, request):
    108108        self.opts = inline
    109109        self.formset = formset
    110         self.fieldsets = fieldsets
     110        self.request = request
    111111
    112112    def __iter__(self):
    113113        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)
    115115        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)
    117117
    118118    def fields(self):
    119119        fk = getattr(self.formset, "fk", None)
     
    133133    """
    134134    A wrapper around an inline form for use in the admin system.
    135135    """
    136     def __init__(self, formset, form, fieldsets, prepopulated_fields, original):
     136    def __init__(self, formset, form, prepopulated_fields, original, request, opts):
    137137        self.formset = formset
    138138        self.original = original
     139        self.request = request
    139140        if original is not None:
    140141            self.original.content_type_id = ContentType.objects.get_for_model(original).pk
    141142        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)
    143144
    144145    def __iter__(self):
    145146        for name, options in self.fieldsets:
Back to Top