From 0bbd8edf68ff27cc86b6cc4ce012a37478b8dd8d Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 12 Mar 2015 13:54:23 +0000 Subject: [PATCH] Set first_published_at on first publish --- wagtail/wagtailcore/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 2268a9e87..35122105a 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -1140,6 +1140,11 @@ class PageRevision(models.Model): # If page goes live clear the approved_go_live_at of all revisions page.revisions.update(approved_go_live_at=None) page.expired = False # When a page is published it can't be expired + + # Set first_published_at if the page is being published now + if page.live and page.first_published_at is None: + page.first_published_at = timezone.now() + page.save() self.submitted_for_moderation = False page.revisions.update(submitted_for_moderation=False)