Skip to content

Commit

Permalink
add error warns on send-fairs form clean to fix #499 and #498
Browse files Browse the repository at this point in the history
  • Loading branch information
bum2 committed Jun 17, 2019
1 parent 1a5c97d commit 53c2cfe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions faircoin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ def clean(self):
if data["to_address"]:
data["to_address"] = data["to_address"].strip()
data["quantity"] = Decimal(data["quantity"])
if data["to_user"] and not data["to_address"]:
touser = data["to_user"]
if touser and touser.faircoin_address():
data["to_address"] = touser.faircoin_address()
if data["to_user"]:
touser = data["to_user"]
touseraddr = touser.faircoin_address()
if touser and touseraddr:
if data["to_address"] and not data["to_address"] == touseraddr:
self.add_error('to_address', _("The destination address is not the destination agent's address!"))
else:
data["to_address"] = touseraddr
if not data["to_address"]:
self.add_error('to_address', _("The destination fair account is missing"))
if data['quantity'] <= 0:
self.add_error('quantity', _("The amount must be positive"))

from django.contrib.auth.models import User
from django.contrib.auth.hashers import check_password
Expand Down

0 comments on commit 53c2cfe

Please sign in to comment.