|
|
|
@ -217,6 +217,21 @@ class StrategyForm(RestrictedFormMixin, ModelForm):
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
if cleaned_data.get("active_management_enabled"):
|
|
|
|
|
# Ensure that no other strategy with this account has active management enabled
|
|
|
|
|
if (
|
|
|
|
|
Strategy.objects.filter(
|
|
|
|
|
account=cleaned_data.get("account"),
|
|
|
|
|
active_management_enabled=True,
|
|
|
|
|
enabled=True,
|
|
|
|
|
)
|
|
|
|
|
.exclude(id=self.instance.id)
|
|
|
|
|
.exists()
|
|
|
|
|
):
|
|
|
|
|
self.add_error(
|
|
|
|
|
"active_management_enabled",
|
|
|
|
|
"You cannot have more than one strategy with active management enabled for the same account.",
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
if not cleaned_data.get("active_management_policy"):
|
|
|
|
|
self.add_error(
|
|
|
|
|
"active_management_policy",
|
|
|
|
|