Skip to content

Commit

Permalink
renamed variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hemant10yadav committed Oct 16, 2024
1 parent 979298c commit 6100128
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions commcare_connect/opportunity/utils/completed_work.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,14 @@ def update_status(completed_works, opportunity_access, compute_payment=True):
opportunity_access.save()


def update_work_payment_date(access: OpportunityAccess, payment_model_ref=None, completed_work_model_ref=None):
def update_work_payment_date(access: OpportunityAccess, payment_model=None, completed_work_model=None):
"""
Dynamically assign models to avoid issues with historical models during migrations.
Top-level imports use the current model, which may not match the schema at migration
time. This ensures we use historical models during migrations and current models in normal execution.
"""
if not payment_model_ref:
payment_model_ref = Payment

if not completed_work_model_ref:
completed_work_model_ref = CompletedWork
payment_model_ref = payment_model or Payment
completed_work_model_ref = completed_work_model or CompletedWork

payments = payment_model_ref.objects.filter(opportunity_access=access).order_by("date_paid")
completed_works = completed_work_model_ref.objects.filter(opportunity_access=access).order_by(
Expand Down

0 comments on commit 6100128

Please sign in to comment.