Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds additional error reasons to SubsidyAccessPolicy #223

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

brobro10000
Copy link
Contributor

@brobro10000 brobro10000 commented Jul 24, 2023

Adds more reasons and an additional error message for learner credit in the SubsidyAccessPolicy model for the can_redeem endpoint.

Additional logic needed within the enterprise-subsidy repository to specify if a subsidy is not active by checking isActive within the subsidy can_redeem endpoint

Pending Tests

Comment on lines 349 to 362
if not content_metadata:
return (False, REASON_CONTENT_NOT_IN_CATALOG, existing_transactions)

if not subsidy_can_redeem_payload.get('can_redeem', False):
return (False, REASON_NOT_ENOUGH_VALUE_IN_SUBSIDY, existing_transactions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic swapped to avoid additional call into the subsidies can_redeem. Check if the content_metadata exist in the catalog before checking on a subsidy level.

return (False, REASON_SUBSIDY_EXPIRED, [])

# inactive policy with spend remaining (could have redeemed)
if not self.active and not self.will_exceed_spend_limit(content_key, content_metadata=content_metadata):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the changes on like 149 are a little sus i think. I synced with @brobro10000 on slack with some suggestions. He's going to take another look at the logic in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to take another look at it after our discussion yesterday 👍🏽

Copy link
Contributor

@macdiesel macdiesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes the logic around the error handling easier to read. Nice work.

@brobro10000 brobro10000 merged commit a7f2af2 into main Jul 25, 2023
2 checks passed
@brobro10000 brobro10000 deleted the hu/ent-7223 branch July 25, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants