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: add active field to subsidies, can-redeem's CanRedeemResult return #138

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

brobro10000
Copy link
Member

Adds an active response to the 'can-redeem' endpoint.

Its purpose is to allow the policies 'can-redeem' endpoint to be able to determine if the subsidy is active and return the correct messaging to the user in the front end

Related to PR: openedx/enterprise-access#223

Description

Describe in a couple of sentences what this PR adds

Testing instructions

Add some, if applicable

Merge checklist

  • All reviewers approved
  • CI build is green
  • Documentation updated (not only docstrings)
  • Commits are squashed

@brobro10000 brobro10000 changed the title feat: add 'active' flag to subsidies, 'can-redeem' endpoint feat: add 'active' parameter to subsidies, 'can-redeem' endpoint Jul 24, 2023
@brobro10000 brobro10000 changed the title feat: add 'active' parameter to subsidies, 'can-redeem' endpoint feat: add 'active' field to subsidies, 'can-redeem' endpoint return Jul 24, 2023
@brobro10000 brobro10000 changed the title feat: add 'active' field to subsidies, 'can-redeem' endpoint return feat: add active field to subsidies, can-redeem's CanRedeemResult return Jul 24, 2023
@brobro10000 brobro10000 force-pushed the hu/ent-7223 branch 4 times, most recently from d3e7698 to 41c55e2 Compare July 24, 2023 19:41
@@ -90,6 +90,7 @@ def can_redeem(subsidy, lms_user_id, content_key):
)
"""
existing_transaction = subsidy.get_committed_transaction_no_reversal(lms_user_id, content_key)
is_active = subsidy.is_active
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the is_active field is not part of the model I would have expected you to calculate the is_active flag here and not just assign it? I don't think this will work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hamzah set me straight:

Ahh the is_active field is computed against the expiration date. There was no need to recompute it again, just assign a value based on the subsidy. If it’s true or false return that value

@brobro10000 brobro10000 merged commit cc09e7d into main Jul 25, 2023
@brobro10000 brobro10000 deleted the hu/ent-7223 branch July 25, 2023 14:58
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