Fix adding asset restrictions
This commit is contained in:
parent
33d8e26c9b
commit
7afdd39af7
|
@ -333,7 +333,7 @@ class AssetRestrictionForm(RestrictedFormMixin, ModelForm):
|
|||
"pairs": "Comma-separated list of pairs to restrict when a webhook is received. This does nothing on its own.",
|
||||
}
|
||||
|
||||
pairs_parsed = forms.BooleanField(widget=forms.HiddenInput)
|
||||
pairs_parsed = forms.BooleanField(widget=forms.HiddenInput, required=False)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(AssetRestrictionForm, self).clean()
|
||||
|
@ -351,5 +351,7 @@ class AssetRestrictionForm(RestrictedFormMixin, ModelForm):
|
|||
return
|
||||
|
||||
cleaned_data["pairs_parsed"] = new_pairs
|
||||
else:
|
||||
cleaned_data["pairs_parsed"] = {}
|
||||
|
||||
return cleaned_data
|
||||
|
|
|
@ -426,7 +426,7 @@ class AssetRestriction(models.Model):
|
|||
name = models.CharField(max_length=255)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
pairs = models.CharField(max_length=4096, null=True, blank=True)
|
||||
pairs_parsed = models.JSONField(null=True, blank=True, default=dict)
|
||||
pairs_parsed = models.JSONField(null=True, blank=True, default=list)
|
||||
|
||||
webhook_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ def get_allowed(strategy, symbol, direction):
|
|||
linked to the strategy.
|
||||
"""
|
||||
|
||||
#asset_group = strategy.
|
||||
# asset_group = strategy.
|
||||
|
|
|
@ -86,6 +86,10 @@ class AssetRestrictionCreate(
|
|||
submit_url_name = "assetrestriction_create"
|
||||
submit_url_args = ["type", "group"]
|
||||
|
||||
def form_invalid(self, form):
|
||||
"""If the form is invalid, render the invalid form."""
|
||||
return self.get(self.request, **self.kwargs, form=form)
|
||||
|
||||
def pre_save_mutate(self, user, obj):
|
||||
try:
|
||||
assetgroup = AssetGroup.objects.get(pk=self.kwargs["group"], user=user)
|
||||
|
|
Loading…
Reference in New Issue