Example #1
0
    def add_view(self, request, form_url="", extra_context=None):

        root_node = self._get_root(request)

        extra_context = extra_context or {}
        extra_context.update({"root_node": root_node})
        return MPTTModelAdmin.add_view(self, request, form_url, extra_context=extra_context)
Example #2
0
    def add_view(self, request, form_url='', extra_context=None):

        root_node = self._get_root(request)

        extra_context = extra_context or {}
        extra_context.update({'root_node': root_node})
        return MPTTModelAdmin.add_view(self,
                                       request,
                                       form_url,
                                       extra_context=extra_context)
Example #3
0
 def get_form(self, request, obj=None, **kwargs):
     f = MPTTModelAdmin.get_form(self, request, obj, **kwargs)
     
     if obj:
         qs = obj.get_root().get_descendants(include_self=True)
     else:
         root_node = self._get_root(request)
         if root_node:
             qs = root_node.get_descendants(include_self=True)
         else:
             qs = Skill.objects.none()
     
     class NewForm(f):
         def __init__(self, *args, **kwargs):
             f.__init__(self, *args, **kwargs)
             self.fields['parent'].queryset =qs
             
     return NewForm
Example #4
0
    def get_form(self, request, obj=None, **kwargs):
        f = MPTTModelAdmin.get_form(self, request, obj, **kwargs)

        if obj:
            qs = obj.get_root().get_descendants(include_self=True)
        else:
            root_node = self._get_root(request)
            if root_node:
                qs = root_node.get_descendants(include_self=True)
            else:
                qs = Skill.objects.none()

        class NewForm(f):
            def __init__(self, *args, **kwargs):
                f.__init__(self, *args, **kwargs)
                self.fields['parent'].queryset = qs

        return NewForm
Example #5
0
 def __init__(self, model, admin_site):
     MPTTModelAdmin.__init__(self, model, admin_site)