-
Notifications
You must be signed in to change notification settings - Fork 2
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: added interaface for processing product coupon assignment sheets #3406
base: master
Are you sure you want to change the base?
Conversation
) | ||
|
||
except CouponAssignmentError as e: | ||
return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 5 days ago
To fix the problem, we need to ensure that detailed error messages are logged on the server side, and a generic error message is returned to the user. This can be achieved by modifying the exception handling block to log the exception message and return a generic error message.
- Import the
logging
module if not already imported. - Log the detailed error message using the
log
object. - Return a generic error message to the user.
-
Copy modified lines R204-R205
@@ -203,3 +203,4 @@ | ||
except CouponAssignmentError as e: | ||
return Response({"error": str(e)}, status=status.HTTP_400_BAD_REQUEST) | ||
log.error(f"CouponAssignmentError: {str(e)}") | ||
return Response({"error": "An error occurred while processing the coupon sheet."}, status=status.HTTP_400_BAD_REQUEST) | ||
|
1eceaef
to
8334619
Compare
cb7910c
to
bcd9eac
Compare
for more information, see https://pre-commit.ci
What are the relevant tickets?
https://github.com/mitodl/hq/issues/6582
Description (What does it do?)
This PR adds the interface for processing product coupon assignment sheets in
ecommerce admin
. The UI will only be accessible to people having permissions to add and update ProductCouponAssignment model.Screenshots (if appropriate):
Users with only adding and deleting a coupon permissions
Users with adding and changing ProductCouponAssignment model permissions
Form Validations when using ID
Form Validations when using Title
Success response from API
Error response from API
How can this be tested?
DRIVE_SERVICE_ACCOUNT_CREDS
environment variableowner
permissionsSheets xPRO
when creating one for local testing.Sheets xPRO
folder, create a spread sheet with name prefixed byEnrollment Codes -
. See this shared drive I created when testing for reference. I would still need to give you access so feel free to request one.Sheets xPRO
in our case)http://localhost:8053/ecommerce/admin/
. You should get a 403ProductCouponAssignment
.Process Coupon AssignmentSheet
link./ecommerce/admin/process-coupon-assignment-sheets/
Process Coupon Sheet
buttonUse Title Sheet
radio button and enter the title of the sheet in the text boxAdditional Context