Skip to content

Commit e391ccb

Browse files
author
Chanita Siridechkun
committed
more checking so that the code can pass unit test.
1 parent bff1592 commit e391ccb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cms/signals.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def post_save_title(instance, raw, created, **kwargs):
6161
# Update descendants only if path changed
6262
application_changed = False
6363

64-
if instance.path != instance.tmp_path and not hasattr(instance, 'tmp_prevent_descendant_update'):
64+
if instance.path != getattr(instance,'tmp_path',None) and not hasattr(instance, 'tmp_prevent_descendant_update'):
6565
descendant_titles = Title.objects.filter(
6666
page__lft__gt=instance.page.lft,
6767
page__rght__lt=instance.page.rght,
@@ -77,13 +77,15 @@ def post_save_title(instance, raw, created, **kwargs):
7777
descendant_title.save()
7878

7979
if not hasattr(instance, 'tmp_prevent_descendant_update') and \
80-
(instance.application_urls != instance.tmp_application_urls or application_changed):
80+
(instance.application_urls != getattr(instance, 'tmp_application_urls', None) or application_changed):
8181
# fire it if we have some application linked to this page or some descendant
8282
cms_signals.application_post_changed.send(sender=Title, instance=instance)
8383

8484
# remove temporary attributes
85-
del(instance.tmp_path)
86-
del(instance.tmp_application_urls)
85+
if getattr( instance, 'tmp_path', None):
86+
del(instance.tmp_path)
87+
if getattr( instance, 'tmp_application_urls' , None):
88+
del(instance.tmp_application_urls)
8789

8890
try:
8991
del(instance.tmp_prevent_descendant_update)

0 commit comments

Comments
 (0)