File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,25 @@ class Experiment(ClusterableModel):
4848 FieldPanel ('status' ),
4949 ]
5050
51+ def __init__ (self , * args , ** kwargs ):
52+ super (Experiment , self ).__init__ (* args , ** kwargs )
53+ self ._initial_status = self .status
54+
55+ def save (self , * args , ** kwargs ):
56+ result = super (Experiment , self ).save (* args , ** kwargs )
57+ if self ._initial_status == 'draft' and self .status == 'live' :
58+ # For any alternative pages that are unpublished, copy the latest draft revision
59+ # to the main table (with is_live=False) so that the revision shown as an alternative
60+ # is not an out-of-date one
61+ for alternative in self .alternatives .select_related ('page' ):
62+ if not alternative .page .live :
63+ revision = alternative .page .get_latest_revision_as_page ()
64+ revision .live = False
65+ revision .has_unpublished_changes = True
66+ revision .save ()
67+
68+ return result
69+
5170 def get_variations (self ):
5271 return [self .control_page ] + [alt .page for alt in self .alternatives .select_related ('page' )]
5372
You can’t perform that action at this time.
0 commit comments