diff -Naur --exclude='*.pyc' django/contrib/admin/options.py /usr/lib/python2.4/site-packages/django/contrib/admin/options.py
old
|
new
|
|
279 | 279 | def get_formsets(self, request, obj=None): |
280 | 280 | for inline in self.inline_instances: |
281 | 281 | yield inline.get_formset(request, obj) |
282 | | |
| 282 | for nested in inline.inline_instances: |
| 283 | yield nested.get_formset(request, obj) |
| 284 | for subnested in nested.inline_instances: |
| 285 | yield subnested.get_formset(request, obj) |
| 286 | |
283 | 287 | def log_addition(self, request, object): |
284 | 288 | """ |
285 | 289 | Log that an object has been successfully added. |
… |
… |
|
603 | 607 | adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj), self.prepopulated_fields) |
604 | 608 | media = self.media + adminForm.media |
605 | 609 | |
| 610 | nested_inlines = [] |
| 611 | subnested_inlines = [] |
| 612 | for inline in self.inline_instances: |
| 613 | for nested in inline.inline_instances: |
| 614 | nested_inlines.append(nested) |
| 615 | for subnested in nested.inline_instances: |
| 616 | subnested_inlines.append(subnested) |
| 617 | all_inlines = self.inline_instances + nested_inlines + subnested_inlines |
| 618 | |
606 | 619 | inline_admin_formsets = [] |
607 | | for inline, formset in zip(self.inline_instances, formsets): |
608 | | fieldsets = list(inline.get_fieldsets(request, obj)) |
609 | | inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, fieldsets) |
610 | | inline_admin_formsets.append(inline_admin_formset) |
611 | | media = media + inline_admin_formset.media |
| 620 | for formset in formsets: |
| 621 | for inline in all_inlines: |
| 622 | if inline.model == formset.model: |
| 623 | fieldsets = list(inline.get_fieldsets(request, obj)) |
| 624 | inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, fieldsets) |
| 625 | inline_admin_formsets.append(inline_admin_formset) |
| 626 | media = media + inline_admin_formset.media |
| 627 | break |
612 | 628 | |
613 | 629 | context = { |
614 | 630 | 'title': _('Change %s') % force_unicode(opts.verbose_name), |
… |
… |
|
759 | 775 | template = None |
760 | 776 | verbose_name = None |
761 | 777 | verbose_name_plural = None |
| 778 | inlines = [] |
762 | 779 | |
763 | 780 | def __init__(self, parent_model, admin_site): |
764 | 781 | self.admin_site = admin_site |
… |
… |
|
769 | 786 | self.verbose_name = self.model._meta.verbose_name |
770 | 787 | if self.verbose_name_plural is None: |
771 | 788 | self.verbose_name_plural = self.model._meta.verbose_name_plural |
772 | | |
| 789 | self.inline_instances = [] |
| 790 | for inline_class in self.inlines: |
| 791 | inline_instance = inline_class(self.model, self.admin_site) |
| 792 | self.inline_instances.append(inline_instance) |
| 793 | |
773 | 794 | def _media(self): |
774 | 795 | from django.conf import settings |
775 | 796 | js = [] |
diff -Naur --exclude='*.pyc' django/contrib/admin/validation.py /usr/lib/python2.4/site-packages/django/contrib/admin/validation.py
old
|
new
|
|
137 | 137 | raise ImproperlyConfigured("'%s.formset' does not inherit from " |
138 | 138 | "BaseModelFormSet." % cls.__name__) |
139 | 139 | |
| 140 | # nested inlines = [] |
| 141 | if hasattr(cls, 'inlines'): |
| 142 | check_isseq(cls, 'inlines', cls.inlines) |
| 143 | for idx, inline in enumerate(cls.inlines): |
| 144 | if not issubclass(inline, BaseModelAdmin): |
| 145 | raise ImproperlyConfigured("'%s.inlines[%d]' does not inherit " |
| 146 | "from BaseModelAdmin." % (cls.__name__, idx)) |
| 147 | if not inline.model: |
| 148 | raise ImproperlyConfigured("'model' is a required attribute " |
| 149 | "of '%s.inlines[%d]'." % (cls.__name__, idx)) |
| 150 | if not issubclass(inline.model, models.Model): |
| 151 | raise ImproperlyConfigured("'%s.inlines[%d].model' does not " |
| 152 | "inherit from models.Model." % (cls.__name__, idx)) |
| 153 | validate_base(inline, inline.model) |
| 154 | validate_inline(inline) |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
140 | 160 | def validate_base(cls, model): |
141 | 161 | opts = model._meta |
142 | 162 | |