-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to polymorphic functionality. refs #138
- Loading branch information
Showing
18 changed files
with
356 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
108 changes: 108 additions & 0 deletions
108
nested_admin/tests/nested_polymorphic/test_polymorphic_add_filtering/admin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
from django.contrib import admin | ||
from django.db import models | ||
from django import forms | ||
|
||
import nested_admin | ||
|
||
from .models import ( | ||
FreeText, Poll, Question, MultipleChoiceGroup, MultipleChoice, Survey, Text, Textarea) | ||
|
||
|
||
class TextInline(nested_admin.NestedTabularInline): | ||
model = Text | ||
extra = 1 | ||
min_num = 1 | ||
max_num = 1 | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class TextareaInline(nested_admin.NestedTabularInline): | ||
model = Textarea | ||
extra = 1 | ||
min_num = 1 | ||
max_num = 1 | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class RadioInline(nested_admin.NestedTabularInline): | ||
model = MultipleChoice | ||
sortable_field_name = "position" | ||
extra = 0 | ||
min_num = 1 | ||
max_num = 8 | ||
radio_fields = {'style': admin.HORIZONTAL} | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class RadioGroupInline(nested_admin.NestedTabularInline): | ||
model = MultipleChoiceGroup | ||
inlines = (RadioInline,) | ||
extra = 0 | ||
min_num = 1 | ||
max_num = 1 | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class DropDownInline(nested_admin.NestedTabularInline): | ||
model = MultipleChoice | ||
sortable_field_name = "position" | ||
extra = 0 | ||
min_num = 1 | ||
max_num = 8 | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class DropDownGroupInline(nested_admin.NestedTabularInline): | ||
model = MultipleChoiceGroup | ||
inlines = (DropDownInline,) | ||
extra = 0 | ||
min_num = 1 | ||
max_num = 1 | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
class QuestionInline(nested_admin.NestedStackedPolymorphicInline): | ||
class FreeTextInline(nested_admin.NestedStackedPolymorphicInline.Child): | ||
model = FreeText | ||
inlines = (TextInline, TextareaInline, DropDownGroupInline) | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
class PollInline(nested_admin.NestedStackedPolymorphicInline.Child): | ||
model = Poll | ||
inlines = (TextInline, RadioGroupInline,) | ||
sortable_field_name = "position" | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
model = Question | ||
extra = 0 | ||
sortable_field_name = "position" | ||
child_inlines = (FreeTextInline, PollInline,) | ||
formfield_overrides = { | ||
models.PositiveSmallIntegerField: {'widget': forms.HiddenInput}, | ||
} | ||
|
||
|
||
@admin.register(Survey) | ||
class SurveyAdmin(nested_admin.NestedPolymorphicModelAdmin): | ||
inlines = (QuestionInline,) |
Oops, something went wrong.