-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix: check for case where client sends null for max_quantity #6344
Conversation
Codecov Report
@@ Coverage Diff @@
## development #6344 +/- ##
============================================
Coverage 65.26% 65.26%
============================================
Files 287 287
Lines 14754 14754
============================================
Hits 9629 9629
Misses 5125 5125
Continue to review full report at Codecov.
|
app/api/schema/discount_codes.py
Outdated
@@ -86,7 +86,7 @@ def validate_quantity(self, data, original_data): | |||
|
|||
DiscountCodeSchemaEvent.quantity_validation_helper(data) | |||
|
|||
if 'tickets_number' in data and 'max_quantity' in data: | |||
if 'tickets_number' in data and 'max_quantity' in data and data['max_quantity'] is not None: |
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.
if 'tickets_number' in data and 'max_quantity' in data and data['max_quantity'] is not None: | |
if data.get('tickets_number') and data.get('max_quantity'): |
app/api/schema/discount_codes.py
Outdated
@@ -149,7 +149,7 @@ def validate_quantity(self, data, original_data): | |||
|
|||
DiscountCodeSchemaTicket.quantity_validation_helper(data) | |||
|
|||
if 'tickets_number' in data and 'max_quantity' in data: | |||
if 'tickets_number' in data and 'max_quantity' in data and data['max_quantity'] is not None: |
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.
Same
app/api/schema/discount_codes.py
Outdated
@@ -149,7 +149,7 @@ def validate_quantity(self, data, original_data): | |||
|
|||
DiscountCodeSchemaTicket.quantity_validation_helper(data) | |||
|
|||
if 'tickets_number' in data and 'max_quantity' in data: | |||
if 'tickets_number' in data and 'max_quantity' in data and data['max_quantity'] is not None: |
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.
if 'tickets_number' in data and 'max_quantity' in data and data['max_quantity'] is not None: | |
if data.get('tickets_number') and data.get('max_quantity'): |
Fixes #6343
There is a case where the client does supply the value for maximum discount codes, by specifying that it is null, this PR handles that case to prevent validation code from breaking.