Skip to content

Commit

Permalink
resource: fix container resource not including children
Browse files Browse the repository at this point in the history
The issue was that the queryset it was building was based on self.model rather than the base class: Model.

self.model was just Container, so that meant it ended up building a queryset that included only sublcasses of Container which ... is only Container, so it returned no children at all.

Also the super().__init__(request, container) call populates the Resource dict with data from the base object (the Container), so move the children under a list (using the key "children").
  • Loading branch information
robvdl committed Mar 14, 2024
1 parent e275e77 commit a93afc5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sambal/resources/container.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ldb import SCOPE_ONELEVEL
from samba.domain.models import Container
from samba.domain.models import Container, Model

from .resource import Resource

Expand All @@ -11,14 +11,15 @@ def __init__(self, request, container):
super().__init__(request, container)

if request.samdb:
queryset = self.model.query(
queryset = Model.query(
request.samdb,
base_dn=container.dn,
scope=SCOPE_ONELEVEL,
polymorphic=True,
)

self["children"] = []
for obj in queryset:
if obj:
resource_class = self.resource_for_model(obj)
self[obj.name] = resource_class(request, obj)
self["children"].append(resource_class(request, obj))

0 comments on commit a93afc5

Please sign in to comment.