nested_admin.tests.two_deep package

Submodules

nested_admin.tests.two_deep.admin module

class SortableWithExtraChildInline(*args, **kwargs)[source]

Bases: nested_admin.nested.NestedStackedInline

extra = 2
inline_classes = ('collapse', 'open')
media
model

alias of nested_admin.tests.two_deep.models.SortableWithExtraChild

sortable_excludes = ['foo']
sortable_field_name = 'position'
class SortableWithExtraRootAdmin(model, admin_site)[source]

Bases: nested_admin.nested.NestedModelAdmin

inlines = [<class 'nested_admin.tests.two_deep.admin.SortableWithExtraChildInline'>]
media
class StackedGroupAdmin(model, admin_site)[source]

Bases: nested_admin.nested.NestedModelAdmin

inlines = [<class 'nested_admin.tests.two_deep.admin.StackedSectionInline'>]
media
class StackedItemInline(*args, **kwargs)[source]

Bases: nested_admin.nested.NestedStackedInline

extra = 0
inline_classes = ('collapse', 'open')
media
model

alias of nested_admin.tests.two_deep.models.StackedItem

sortable_field_name = 'position'
class StackedSectionInline(*args, **kwargs)[source]

Bases: nested_admin.nested.NestedStackedInline

extra = 0
inline_classes = ('collapse', 'open')
inlines = [<class 'nested_admin.tests.two_deep.admin.StackedItemInline'>]
media
model

alias of nested_admin.tests.two_deep.models.StackedSection

sortable_field_name = 'position'
class TabularGroupAdmin(model, admin_site)[source]

Bases: nested_admin.nested.NestedModelAdmin

inlines = [<class 'nested_admin.tests.two_deep.admin.TabularSectionInline'>]
media
class TabularItemInline(*args, **kwargs)[source]

Bases: nested_admin.nested.NestedTabularInline

extra = 0
media
model

alias of nested_admin.tests.two_deep.models.TabularItem

sortable_field_name = 'position'
class TabularSectionInline(*args, **kwargs)[source]

Bases: nested_admin.nested.NestedTabularInline

extra = 0
inlines = [<class 'nested_admin.tests.two_deep.admin.TabularItemInline'>]
media
model

alias of nested_admin.tests.two_deep.models.TabularSection

sortable_field_name = 'position'

nested_admin.tests.two_deep.models module

class GroupAbstract(*args, **kwargs)[source]

Bases: django.db.models.base.Model

class Meta[source]
abstract = False
slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class ItemAbstract(*args, **kwargs)[source]

Bases: django.db.models.base.Model

class Meta[source]
abstract = False
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class SectionAbstract(*args, **kwargs)[source]

Bases: django.db.models.base.Model

class Meta[source]
abstract = False
position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class SortableWithExtraChild(id, slug, root, position, foo)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

foo

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
position

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

root

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

root_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class SortableWithExtraRoot(id, slug)[source]

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sortablewithextrachild_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class StackedGroup(id, slug)[source]

Bases: nested_admin.tests.two_deep.models.GroupAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
section_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class StackedItem(id, name, position, section, upload)[source]

Bases: nested_admin.tests.two_deep.models.ItemAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
section

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

section_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

upload

The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assigns a file object on assignment so you can do:

>>> with open('/path/to/hello.world', 'r') as f:
...     instance.file = File(f)
class StackedSection(id, slug, position, group)[source]

Bases: nested_admin.tests.two_deep.models.SectionAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

group

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

group_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
class TabularGroup(id, slug)[source]

Bases: nested_admin.tests.two_deep.models.GroupAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
section_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class TabularItem(id, name, position, section)[source]

Bases: nested_admin.tests.two_deep.models.ItemAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
section

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

section_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class TabularSection(id, slug, position, group)[source]

Bases: nested_admin.tests.two_deep.models.SectionAbstract

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

group

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

group_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>

nested_admin.tests.two_deep.tests module

class InlineAdminTestCaseMixin[source]

Bases: object

classmethod setUpClass()[source]
test_add_item_to_empty()[source]
test_add_remove_items_in_new_section_dragging_existing_items()[source]

Tests for a regression that could be reproduced with the following steps:

  1. Begin with one section, with at least one item in it.
  2. Create a new section
  3. Create three items in the new section
  4. Remove the first of the new items
  5. Drag the first of the existing items into the first position in the new section.

6. Remove the second item in the new section 8. Save

Expected outcome:
The dragged item from the existing section should have been moved to the new section.
Outcome with bug:
The item has not moved.
test_add_section_to_empty()[source]
test_delete_item()[source]
test_delete_item_undelete_section()[source]

Test that, if an item is deleted, then the section is deleted, and then the section is undeleted, that the item stays deleted.

test_delete_section()[source]
test_delete_section_after_dragging_item_away()[source]
test_delete_undelete_section_after_dragging_item_away()[source]
test_drag_existing_item_to_new_section_and_back()[source]
test_drag_first_item_to_new_section()[source]

Test dragging the first of several items in a pre-existing section into a newly created section.

test_drag_first_item_to_new_section_after_removing_item()[source]

Test dragging the first of several items in a pre-existing section into a newly created section after having added two items and then removing one of those items.

test_drag_into_new_section_after_adding_and_removing_preceding_section()[source]
test_drag_item_create_invalid_new_item_then_drag_back_after_validation_error_removing_invalid_item()[source]

Tests regression of a scenario after encountering a validation error.

Steps to reproduce:
  1. Begin with at least two items in each section
  2. Drag one of the items from the first section into the second
  3. Create an invalid item in the first section
  4. Save, encounter a validation error
  5. Drag the invalid item back to the first group
  6. Remove the invalid item
  7. Save, get a 500 Internal Server Error
test_drag_item_from_last_position()[source]
test_drag_item_to_empty_section()[source]
test_drag_item_to_first_position()[source]
test_drag_item_to_last_position()[source]
test_drag_item_to_new_empty_section()[source]
test_drag_last_item_between_sections()[source]
test_drag_middle_item_between_sections()[source]
test_drag_middle_item_between_sections_after_adding_new_item()[source]
test_drag_middle_item_between_sections_after_adding_new_item_to_other_section()[source]
test_drag_new_item_between_sections()[source]
test_position_update_bug()[source]
test_remove_item()[source]
test_swap_first_two_items_between_sections()[source]
class TestSortablesWithExtra(methodName='runTest')[source]

Bases: nested_admin.tests.base.BaseNestedAdminTestCase

nested_models = (<class 'nested_admin.tests.two_deep.models.SortableWithExtraChild'>,)
root_model

alias of nested_admin.tests.two_deep.models.SortableWithExtraRoot

test_blank_extra_inlines_validation()[source]
test_blank_extra_inlines_validation_with_change()[source]
class TestStackedInlineAdmin(methodName='runTest')[source]

Bases: nested_admin.tests.two_deep.tests.InlineAdminTestCaseMixin, nested_admin.tests.base.BaseNestedAdminTestCase

nested_models = (<class 'nested_admin.tests.two_deep.models.StackedSection'>, <class 'nested_admin.tests.two_deep.models.StackedItem'>)
root_model

alias of nested_admin.tests.two_deep.models.StackedGroup

test_add_item_inline_label_update()[source]
test_upload_file()[source]
class TestTabularInlineAdmin(methodName='runTest')[source]

Bases: nested_admin.tests.two_deep.tests.InlineAdminTestCaseMixin, nested_admin.tests.base.BaseNestedAdminTestCase

nested_models = (<class 'nested_admin.tests.two_deep.models.TabularSection'>, <class 'nested_admin.tests.two_deep.models.TabularItem'>)
root_model

alias of nested_admin.tests.two_deep.models.TabularGroup

Module contents