Skip to content

Commit

Permalink
Fix for django v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed May 2, 2024
1 parent 0f41a61 commit e8283f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
45 changes: 25 additions & 20 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,26 +909,31 @@ def update_invoice(cls, order, user, invoice, routing_budget_ppm):
if not payout["valid"]:
return False, payout["context"]

order.payout, _ = LNPayment.objects.update_or_create(
concept=LNPayment.Concepts.PAYBUYER,
type=LNPayment.Types.NORM,
sender=User.objects.get(username=ESCROW_USERNAME),
# In case this user has other payouts, update the one related to this order.
order_paid_LN=order,
receiver=user,
routing_budget_ppm=routing_budget_ppm,
routing_budget_sats=routing_budget_sats,
# if there is a LNPayment matching these above, it updates that one with defaults below.
defaults={
"invoice": invoice,
"status": LNPayment.Status.VALIDI,
"num_satoshis": num_satoshis,
"description": payout["description"],
"payment_hash": payout["payment_hash"],
"created_at": payout["created_at"],
"expires_at": payout["expires_at"],
},
)
if order.payout:
order.payout.invoice = invoice
order.payout.status = LNPayment.Status.VALIDI
order.payout.num_satoshis = num_satoshis
order.payout.description = payout["description"]
order.payout.payment_hash = payout["payment_hash"]
order.payout.created_at = payout["created_at"]
order.payout.expires_at = payout["expires_at"]
order.payout.save()
else:
order.payout = LNPayment.objects.create(
concept=LNPayment.Concepts.PAYBUYER,
type=LNPayment.Types.NORM,
sender=User.objects.get(username=ESCROW_USERNAME),
receiver=user,
routing_budget_ppm=routing_budget_ppm,
routing_budget_sats=routing_budget_sats,
invoice=invoice,
status=LNPayment.Status.VALIDI,
num_satoshis=num_satoshis,
description=payout["description"],
payment_hash=payout["payment_hash"],
created_at=payout["created_at"],
expires_at=payout["expires_at"],
)

order.is_swap = False
order.save(update_fields=["payout", "is_swap"])
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
django==4.2.11
django==5.0.4
django-admin-relation-links==0.2.5
django-celery-beat==2.6.0
django-celery-results==2.5.1
Expand All @@ -16,7 +16,7 @@ Pillow==10.1.0
python-decouple==3.8
requests==2.31.0
ring==0.10.1
git+https://github.com/RoboSats/Robohash.git
git+https://github.com/RoboSats/Robohash.git@master
gunicorn==22.0.0
psycopg2==2.9.9
SQLAlchemy==2.0.16
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==7.5.0
ruff==0.4.2
drf-openapi-tester @ git+https://github.com/Reckless-Satoshi/drf-openapi-tester.git@soften-django-requirements
git+https://github.com/Reckless-Satoshi/drf-openapi-tester.git@soften-django-requirements
pre-commit==3.7.0

0 comments on commit e8283f2

Please sign in to comment.