Beispiel #1
0
 def __init__(self, form, name=None, readonly_fields=(), fields=(), classes=(),
   description=None, model_admin=None, inlines=None):
     self.inlines = inlines
     if not inlines:
         for field in fields:
             if is_inline(field):
                 # an inline is in the field list, but the list of inlines is empty
                 pass
     super(OrderedFieldset, self).__init__(form, name, readonly_fields, fields, classes, description, model_admin)
Beispiel #2
0
 def __iter__(self):
     for field in self.fields:
         if not is_inline(field):
             fieldline = helpers.Fieldline(self.form, field, self.readonly_fields, model_admin=self.model_admin)
             elem = OrderedElement(fieldline=fieldline)
             yield elem
         else:
             field = decode_inline(field)
             for inline in self.inlines:
                 if hasattr(inline.opts, 'parent_fk_name'):
                     if inline.opts.parent_fk_name == field:
                         elem = OrderedElement(inline=inline)
                         yield elem
                 elif hasattr(inline.formset, 'prefix'):
                     if inline.formset.prefix == field:
                         elem = OrderedElement(inline=inline)
                         yield elem
                 else:
                     raise InlineError('Incorrect inline: no opts.parent_fk_name or formset.prefix found')