Skip to content

Commit 619a403

Browse files
♻️(backend) refactor confirm_student_signature in base signature backend
We needed to update the was we retrieve the batch order from a contract into the signature backend.
1 parent a60d68c commit 619a403

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/backend/joanie/signature/backends/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def _confirm_student_signature(self, contract):
5151
contract.student_signed_on = django_timezone.now()
5252
contract.save()
5353

54-
if contract.batch_orders.count() == 1:
55-
batch_order = contract.batch_orders.first()
54+
if batch_order := contract.batch_order:
5655
flow = batch_order.flow
5756
if batch_order.uses_purchase_order:
5857
flow.update() # Transition to `signing` state now and second call is to `completed`

src/backend/joanie/signature/backends/dummy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_signature_invitation_link(self, recipient_email: str, reference_ids: lis
6262
"finished" if contract.student_signed_on is not None else "signed"
6363
)
6464
# Case for batch order's contract
65-
if contract.batch_orders.exists() and event_target == "signed":
65+
if contract.batch_order and event_target == "signed":
6666
self.confirm_signature(reference_id)
6767

6868
return (
@@ -80,7 +80,7 @@ def delete_signing_procedure(self, reference_id: str):
8080
# For case of batch order, we should take away the signature of the buyer because
8181
# it's marked when calling `get_signature_invitation_link`
8282
contract = models.Contract.objects.get(signature_backend_reference=reference_id)
83-
if contract.batch_orders.exists():
83+
if contract.batch_order:
8484
contract.student_signed_on = None
8585
contract.save()
8686

0 commit comments

Comments
 (0)