Skip to content

Commit

Permalink
Fixed #864 -- Ensuring we don't use the MP_NodeQuerySet for the Produ…
Browse files Browse the repository at this point in the history
…cts (which don't make use of mp_tree)
  • Loading branch information
alextreme committed Oct 26, 2022
1 parent fb8c3b8 commit 9d4b2fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from django.db import models

from treebeard.mp_tree import MP_NodeQuerySet


class PublishedQueryset(MP_NodeQuerySet):
class PublishedQueryset(models.QuerySet):
def published(self):
return self.filter(published=True)

def draft(self):
return self.filter(published=False)


class CategoryPublishedQueryset(MP_NodeQuerySet):
def published(self):
return self.filter(published=True)

Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/pdc/models/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from treebeard.exceptions import InvalidMoveToDescendant
from treebeard.mp_tree import MP_MoveHandler, MP_Node

from ..managers import PublishedQueryset
from ..managers import CategoryPublishedQueryset


class PublishedMoveHandler(MP_MoveHandler):
Expand Down Expand Up @@ -62,7 +62,7 @@ class Category(MP_Node):
)

node_order_by = ["slug"]
objects = PublishedQueryset.as_manager()
objects = CategoryPublishedQueryset.as_manager()

class Meta:
verbose_name = _("Category")
Expand Down

0 comments on commit 9d4b2fc

Please sign in to comment.