-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Rewrote Credit API #10634
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
Rewrote Credit API #10634
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| """Exceptions raised by the credit API. """ | ||
| from __future__ import unicode_literals | ||
| from django.utils.translation import ugettext_lazy as _ | ||
| from rest_framework import status | ||
| from rest_framework.exceptions import APIException | ||
|
|
||
| # TODO: Cleanup this mess! ECOM-2908 | ||
|
|
||
|
|
||
| class CreditApiBadRequest(Exception): | ||
|
|
@@ -56,3 +62,25 @@ class InvalidCreditStatus(CreditApiBadRequest): | |
| The status is not either "approved" or "rejected". | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| class InvalidCreditRequest(APIException): | ||
| """ API request is invalid. """ | ||
| status_code = status.HTTP_400_BAD_REQUEST | ||
|
|
||
|
|
||
| class UserNotEligibleException(InvalidCreditRequest): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this is similar to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: can
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe. It will involve touching other code, which I initially avoided to limit the scope of these changes. Let's see...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to leave this as-is for now. The API rewrite is risky enough without changing other components.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works for me.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Seems like the right to do to reduce risk. But do we have / can we create a ticket to track this clean up task once the rewrite is solidly in place?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ECOM-2908 created. |
||
| """ User not eligible for credit for a given course. """ | ||
|
|
||
| def __init__(self, course_key, username): | ||
| detail = _('[{username}] is not eligible for credit for [{course_key}].').format(username=username, | ||
| course_key=course_key) | ||
| super(UserNotEligibleException, self).__init__(detail) | ||
|
|
||
|
|
||
| class InvalidCourseKey(InvalidCreditRequest): | ||
| """ Course key is invalid. """ | ||
|
|
||
| def __init__(self, course_key): | ||
| detail = _('[{course_key}] is not a valid course key.').format(course_key=course_key) | ||
| super(InvalidCourseKey, self).__init__(detail) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own edification, why are we removing the feature flag? Was it used before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was used, but it isn't really needed. If we don't want to use the Credit API...don't use it. Additionally, the feature is fully rolled-out. The odds of us disabling this API are quite low.