Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support user declared inlines

  • Loading branch information...
commit 623ce96545db06696650544b2566701f873921a3 1 parent 74a463f
@atkinson atkinson authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 eventtools/admin.py
View
23 eventtools/admin.py
@@ -237,15 +237,34 @@ class _EventAdmin(SuperModel):
change_form_template = 'admin/eventtools/event.html'
save_on_top = True
prepopulated_fields = {'slug': ('title', )}
- inlines = [
+
+ _inlines = [
OccurrenceInline(EventModel.OccurrenceModel()),
GeneratorInline(EventModel.GeneratorModel()),
]
+
if show_exclusions:
- inlines += [
+ _inlines += [
ExclusionInline(EventModel.ExclusionModel()),
]
+ # Legacy Django < 1.4
+ if not DJANGO14:
+ if hasattr(self, 'inline_instances'):
+ inline_instances += _inlines
+ else:
+ inline_instances = _inlines
+
+ # Django 1.4+
+ def get_inline_instances(self, request):
+ # Get any regular Django inlines the user may have defined.
+ inline_instances = super(_EventAdmin, self).get_inline_instances(request)
+ for inline_class in self._inlines:
+ inline_instance = inline_class(self.model, self.admin_site)
+ inline_instances.append( inline_instance )
+
+ return inline_instances
+
def __init__(self, *args, **kwargs):
super(_EventAdmin, self).__init__(*args, **kwargs)
self.occurrence_model = EventModel.OccurrenceModel()
Please sign in to comment.
Something went wrong with that request. Please try again.