kopia lustrzana https://github.com/wagtail/wagtail
Add PageQuerySet.ever_live() and PageQueryset.never_live() filters
rodzic
b062c22331
commit
d8c2e33505
|
@ -50,6 +50,22 @@ Reference
|
|||
|
||||
unpublished_pages = Page.objects.not_live()
|
||||
|
||||
.. automethod:: ever_live
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
published_or_once_published_pages = Page.objects.ever_live()
|
||||
|
||||
.. automethod:: never_live
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
never_published_pages = Page.objects.never_live()
|
||||
|
||||
.. automethod:: in_menu
|
||||
|
||||
Example:
|
||||
|
|
|
@ -164,6 +164,23 @@ class PageQuerySet(SearchableQuerySetMixin, TreeQuerySet):
|
|||
"""
|
||||
return self.exclude(self.live_q())
|
||||
|
||||
def ever_live_q(self):
|
||||
return Q(Q(last_published_at__isnull=False) | Q(live=True))
|
||||
|
||||
def ever_live(self):
|
||||
"""
|
||||
This filters the QuerySet to only contain pages that have at some
|
||||
point in their history been published.
|
||||
"""
|
||||
return self.filter(self.ever_live_q())
|
||||
|
||||
def never_live(self):
|
||||
"""
|
||||
This filters the QuerySet to only contain pages that have never
|
||||
been published before (have always been drafts).
|
||||
"""
|
||||
return self.exclude(self.ever_live_q())
|
||||
|
||||
def in_menu_q(self):
|
||||
return Q(show_in_menus=True)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue