fix validate trade form
This commit is contained in:
parent
adad689acd
commit
86f3c3f483
|
@ -642,9 +642,18 @@ class TradeForm(NewActionForm):
|
||||||
def validate(self, extra_validators=None):
|
def validate(self, extra_validators=None):
|
||||||
is_valid = super().validate(extra_validators)
|
is_valid = super().validate(extra_validators)
|
||||||
|
|
||||||
if not self.confirm and not self.code:
|
if not self.confirm.data and not self.code.data:
|
||||||
self.code.errors = ["If you don't want confirm, you need a code"]
|
self.code.errors = ["If you don't want confirm, you need a code"]
|
||||||
is_valid = False
|
is_valid = False
|
||||||
|
|
||||||
return is_valid
|
if self.confirm.data and not (self.receiver.data or self.supplier.data):
|
||||||
|
errors = ["If you want confirm, you need a email"]
|
||||||
|
if not self.receiver.data:
|
||||||
|
self.receiver.errors = errors
|
||||||
|
|
||||||
|
if not self.supplier.data:
|
||||||
|
self.supplier.errors = errors
|
||||||
|
|
||||||
|
is_valid = False
|
||||||
|
|
||||||
|
return is_valid
|
||||||
|
|
Reference in New Issue