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

fix: check for case where client sends null for max_quantity #6344

Merged
merged 1 commit into from
Aug 10, 2019

Conversation

abhinavk96
Copy link
Contributor

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.

@codecov
Copy link

codecov bot commented Aug 10, 2019

Codecov Report

Merging #6344 into development will not change coverage.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #6344   +/-   ##
============================================
  Coverage        65.26%   65.26%           
============================================
  Files              287      287           
  Lines            14754    14754           
============================================
  Hits              9629     9629           
  Misses            5125     5125
Impacted Files Coverage Δ
app/api/schema/discount_codes.py 59.25% <50%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1148bd...439d3cf. Read the comment docs.

@@ -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:
Copy link
Member

@iamareebjamal iamareebjamal Aug 10, 2019

Choose a reason for hiding this comment

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

Suggested change
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'):

@@ -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:
Copy link
Member

Choose a reason for hiding this comment

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

Same

@@ -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:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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'):

@iamareebjamal iamareebjamal merged commit 7fc76cb into fossasia:development Aug 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discount codes patch: 500 internal server error
2 participants