Skip to content

Commit

Permalink
Merge pull request OskarPersson#34 from chrisyoulden/master
Browse files Browse the repository at this point in the history
Fix for issue 15.
  • Loading branch information
s-block authored Mar 2, 2017
2 parents d6fbc09 + 1d4f5de commit cfa5a07
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion nested_inline/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Media:
css = {
"all": ('admin/css/forms-nested.css',)
}
js = ('admin/js/inlines-nested.js',)
js = ('admin/js/inlines-nested%s.js' % ('' if settings.DEBUG else '.min'),)

def get_inline_instances(self, request, obj=None):
inline_instances = []
Expand Down Expand Up @@ -245,6 +245,7 @@ def add_view(self, request, form_url='', extra_context=None):
'errors': helpers.AdminErrorList(form, formsets),
'app_label': opts.app_label,
}
context.update(self.admin_site.each_context(request))
context.update(extra_context or {})
return self.render_change_form(request, context, form_url=form_url, add=True)

Expand Down Expand Up @@ -342,6 +343,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
'errors': helpers.AdminErrorList(form, formsets),
'app_label': opts.app_label,
}
context.update(self.admin_site.each_context(request))
context.update(extra_context or {})
return self.render_change_form(request, context, change=True, obj=obj, form_url=form_url)

Expand Down
2 changes: 1 addition & 1 deletion nested_inline/static/admin/js/inlines-nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
var showAddButton = get_max_forms(options.prefix) === '' || (get_max_forms(options.prefix) - get_no_forms(options.prefix)) > 0;
if ($this.length && showAddButton) {
var addButton;
if ($this.attr("tagName") == "TR") {
if ($this.prop("tagName") == "TR") {
// If forms are laid out as table rows, insert the
// "add" button in a new table row:
var numCols = this.eq(-1).children().length;
Expand Down
2 changes: 1 addition & 1 deletion nested_inline/static/admin/js/inlines-nested.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>{{ recursive_formset.opts.verbose_name_plural|capfirst }}</h2>
<script type="text/javascript">
(function($) {
$(document).ready(function($) {
var rows = "#{{ recursive_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
var rows = "#{{ recursive_formset.formset.prefix }}-group .tabular.inline-related:first tbody:first > tr";
var alternatingRows = function(row) {
$(rows).not(".add-row").removeClass("row1 row2")
.filter(":even").addClass("row1").end()
Expand Down

0 comments on commit cfa5a07

Please sign in to comment.