fix: do not save the domain if not necessary.

it will also avoid the trigger of two post_save signals for the domain,
which can lead to unexpected issues.

see #1380
This commit is contained in:
Antoine Nguyen
2018-01-31 11:42:44 +01:00
parent c9f818cf84
commit 5164ecdfdf
+3 -2
View File
@@ -37,6 +37,7 @@ class RelayDomainFormGeneral(tr_forms.TransportForm):
instance.pattern = domain.name
instance.service = "relay"
instance.save()
domain.transport = instance
domain.save(update_fields=["transport"])
if not domain.transport:
domain.transport = instance
domain.save(update_fields=["transport"])
return instance