Skip to content

Commit

Permalink
feat: Reorder error messaging from can_redeem
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Jul 26, 2023
1 parent 41ebf59 commit 0086e9b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions enterprise_access/apps/subsidy_access_policy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,6 @@ def can_redeem(self, lms_user_id, content_key, skip_customer_user_check=False):
active_subsidy = subsidy_can_redeem_payload.get('active', False)
existing_transactions = subsidy_can_redeem_payload.get('all_transactions', [])

# inactive subsidy
if not active_subsidy:
return (False, REASON_SUBSIDY_EXPIRED, [])

# inactive policy
if not self.active:
return (False, REASON_POLICY_EXPIRED, [])

# learner not associated to enterprise
if not skip_customer_user_check:
if not self.lms_api_client.enterprise_contains_learner(self.enterprise_customer_uuid, lms_user_id):
Expand All @@ -356,6 +348,16 @@ def can_redeem(self, lms_user_id, content_key, skip_customer_user_check=False):
if not content_metadata:
return (False, REASON_CONTENT_NOT_IN_CATALOG, existing_transactions)

# TODO: Add Course Upgrade/Registration Deadline Passed Error here

# inactive subsidy
if not active_subsidy:
return (False, REASON_SUBSIDY_EXPIRED, [])

# inactive policy
if not self.active:
return (False, REASON_POLICY_EXPIRED, [])

# can_redeem false from subsidy
if not subsidy_can_redeem_payload.get('can_redeem', False):
return (False, REASON_NOT_ENOUGH_VALUE_IN_SUBSIDY, existing_transactions)
Expand Down

0 comments on commit 0086e9b

Please sign in to comment.