mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-03 04:54:45 +00:00
Fire page_published and page_unpublished signals from scheduled publishing
This commit is contained in:
parent
dc62ebe3a1
commit
3b28b85f58
1 changed files with 9 additions and 0 deletions
|
|
@ -5,7 +5,9 @@ from optparse import make_option
|
|||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import dateparse, timezone
|
||||
|
||||
from wagtail.wagtailcore.models import Page, PageRevision
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
|
||||
|
||||
def revision_date_expired(r):
|
||||
|
|
@ -56,6 +58,10 @@ class Command(BaseCommand):
|
|||
else:
|
||||
expired_pages.update(expired=True, live=False)
|
||||
|
||||
# Fire page_unpublished signal for all expired pages
|
||||
for page in expired_pages:
|
||||
page_unpublished.send(sender=page.specific_class, instance=page.specific)
|
||||
|
||||
# 2. get all page revisions for moderation that have been expired
|
||||
expired_revs = [
|
||||
r for r in PageRevision.objects.filter(
|
||||
|
|
@ -108,3 +114,6 @@ class Command(BaseCommand):
|
|||
# just run publish for the revision -- since the approved go
|
||||
# live datetime is before now it will make the page live
|
||||
rp.publish()
|
||||
|
||||
# Fire page_published signal
|
||||
page_unpublished.send(sender=rp.page.specific_class, instance=rp.page.specific)
|
||||
|
|
|
|||
Loading…
Reference in a new issue