Skip to content

Commit a7b7ca0

Browse files
committed
Update published_at date
1 parent 80ed549 commit a7b7ca0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

publisher/models.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def clone(self, overrides=None):
105105
return cloned_obj
106106

107107
@assert_draft
108-
def publish(self, overrides=None):
108+
def publish(self, overrides=None, dry_publish=False):
109109
if overrides is None:
110110
overrides = []
111111

@@ -114,10 +114,6 @@ def publish(self, overrides=None):
114114
# Reference self for readability
115115
draft_obj = self
116116

117-
# Set the published date if this is the first time the page has been published
118-
if not draft_obj.publisher_linked:
119-
draft_obj.publisher_published_at = timezone.now()
120-
121117
# Duplicate the draft object and set to published
122118
publish_obj = self.__class__.objects.get(pk=self.pk)
123119

@@ -130,7 +126,8 @@ def publish(self, overrides=None):
130126
publish_obj.publisher_draft = draft_obj
131127
publish_obj.publisher_is_draft = False
132128
publish_obj.publisher_is_published = True
133-
publish_obj.publisher_published_at = draft_obj.publisher_published_at
129+
if not dry_publish:
130+
publish_obj.publisher_published_at = timezone.now()
134131

135132
for override_field in overrides:
136133
setattr(publish_obj, override_field[0], override_field[1])

0 commit comments

Comments
 (0)