The publish_scheduled_pages management command does three actions:
* Gets live pages which have an expiry_datetime that has passed and set
expired = True and live = False
* Gets all revisions on the moderation queue which have an expiry_datetime
that has passed and remove them from the moderation queue
* Gets all revisions that have an approved_go_live_datetime that has
passed. For each one of them the publish() method of the revision is
called which will perform the required actions for making live this
version of the page.
Finally, a dryrun parameter has been added to the management command. If
this parameter is used then the pages that pass the tests for each of the
above lists will be printed.
The logic for publishing a page exists in the create and edit views of
wagtailadmin.views.pages and in the publish methodd of hte PageRevision
model.
When a page is created and published (create view), if it has a go_live
in the future then it will not be live but the revision that will be
created will have the approved_go_live set to the corresponding datetime.
If the page is just saved or submitted for moderation the normal flow
will be followed.
When a page is edited and published (edit view):
* The approved_go_live_datetime will be cleared for all older revisions of
that page.
* If the edit has a go_live in the future then the new revision that will
be crated will have the approved_go_live set to that datetime. Also the
live attribute of the page will be set to False.
If the page is edited and not published the normal flow will be followed.
When a submitted for moderation page is published (publish method):
* If it has a go_live in the future then the live attribute will be set to
False, the approved_go_live_datetime of the revision will be set to the
go_live_datetime of the page and the approved_go_live_datetime of all
other revisions will be cleared.
* If it does not have a go_live in the future then the page will be live
and the approved_go_live_dattime of all other revisions will be cleard
Finally, if a page is unpublished then then approved_go_live_datetime of
all revisions of that page will be cleared.
Also add a clean method to Page to check that expiry date is in the
future and that go live date is before expiry date. In order to display
the correct error message the views/pages.py view has to be changed to
display the error message from clean.
Finally add the migration for the new fields.