Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed root_obj in nested inlines #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions djrulengine/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms
from django.contrib import admin
from django.core.urlresolvers import resolve
from nested_inline.admin import (
NestedTabularInline, NestedStackedInline, NestedModelAdmin)
from .models import RuleContext, Rule, Condition, ContextValue
Expand All @@ -22,15 +21,8 @@ class ConditionInline(NestedTabularInline):
fk_name = 'rule'
extra = 1

def get_rule_context_from_request(self, request):
resolved = resolve(request.path_info)
if resolved.args:
return RuleContext.objects.get(pk=resolved.args[0])
return None

def get_formset(self, request, obj=None, **kwargs):
parent = self.get_rule_context_from_request(request)
self.form.rule_context = parent
self.form.rule_context = self.root_obj
return super(ConditionInline, self).get_formset(request, obj, **kwargs)


Expand Down