mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Set expired = False when publishing pages both ...
in views and models and refactor code a bit.
This commit is contained in:
parent
1ebe234a7e
commit
89f2d76bfd
2 changed files with 11 additions and 8 deletions
|
|
@ -178,15 +178,16 @@ def create(request, content_type_app_name, content_type_model_name, parent_page_
|
|||
future_go_live = go_live_datetime and go_live_datetime > timezone.now()
|
||||
approved_go_live_datetime = None
|
||||
|
||||
if is_publishing and not future_go_live:
|
||||
page.live = True
|
||||
page.has_unpublished_changes = False
|
||||
elif is_publishing and future_go_live:
|
||||
page.live = False
|
||||
# Set approved_go_live_datetime only if is publishing
|
||||
# and the future_go_live is actually in future
|
||||
approved_go_live_datetime = go_live_datetime
|
||||
if is_publishing:
|
||||
page.has_unpublished_changes = False
|
||||
page.expired = False
|
||||
if future_go_live:
|
||||
page.live = False
|
||||
# Set approved_go_live_datetime only if is publishing
|
||||
# and the future_go_live is actually in future
|
||||
approved_go_live_datetime = go_live_datetime
|
||||
else:
|
||||
page.live = True
|
||||
else:
|
||||
page.live = False
|
||||
page.has_unpublished_changes = True
|
||||
|
|
@ -267,6 +268,7 @@ def edit(request, page_id):
|
|||
|
||||
if is_publishing:
|
||||
page.has_unpublished_changes = False
|
||||
page.expired = False
|
||||
if future_go_live:
|
||||
page.live = False
|
||||
# Set approved_go_live_datetime only if publishing
|
||||
|
|
|
|||
|
|
@ -717,6 +717,7 @@ class PageRevision(models.Model):
|
|||
page.live = True
|
||||
# If page goes live clear the approved_go_live_datetime of all revisions
|
||||
page.revisions.update(approved_go_live_datetime=None)
|
||||
page.expired = False # When a page is published it can't be expired
|
||||
page.save()
|
||||
self.submitted_for_moderation = False
|
||||
page.revisions.update(submitted_for_moderation=False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue