-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: add checks for discount value #5880
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: add checks for discount value #5880
Conversation
2bd4190 to
352539f
Compare
Codecov Report
@@ Coverage Diff @@
## development #5880 +/- ##
===============================================
- Coverage 66.17% 66.17% -0.01%
===============================================
Files 285 285
Lines 14133 14118 -15
===============================================
- Hits 9353 9343 -10
+ Misses 4780 4775 -5
Continue to review full report at Codecov.
|
2b47e7f to
a8ba942
Compare
a8ba942 to
57148a6
Compare
a6340b8 to
444ba63
Compare
444ba63 to
1b298e3
Compare
1b298e3 to
e89e7be
Compare
|
@iamareebjamal I've added a new file to add new tests in |
e89e7be to
2d062c2
Compare
2d062c2 to
9d204a2
Compare
|
Please handle percent by marshmallow schema |
dd50f80 to
d65c2e7
Compare
a2ef6a1 to
e486741
Compare
|
@CosmicCoder96 @iamareebjamal I've finalized my PR and included checks and tests for free tickets. |
|
The error was straightforward and right there in the clear:
Yes |
2f7e1b6 to
a989538
Compare
added tests Updated tests adds check for negative discount amount and percent removes validation for event discount code adds check for free tickets
a989538 to
04a9b28
Compare
|
@iamareebjamal @uds5501 @CosmicCoder96 I've finalized the PR and fix the build. Please review |
|
@iamareebjamal please review |
|
@iamareebjamal @niranjan94 please review |
kushthedude
left a comment
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.
LGTM !!
| if 'tickets' in data: | ||
| for ticket in data['tickets']: | ||
| ticket_object = Ticket.query.filter_by(id=ticket).one() | ||
| if not ticket_object.price: |
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.
shouldn't it be compared to zero ? for clarity?
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.
@CosmicCoder96 actually we are allowing none for price attribute of ticket. Though for front-end we send 0 in case ticket price is not set but server is also for android. Maybe there are tickets present with None as ticket price so it may cause discrepancies
price = fields.Float(validate=lambda n: n >= 0, allow_none=True)
I checked it just now. Should I compare explicitly?
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.
@shreyanshdwivedi okay, cool then don't change it.
added tests Updated tests adds check for negative discount amount and percent removes validation for event discount code adds check for free tickets
Fixes #5874
Checklist
developmentbranch.Short description of what this resolves:
Currently their is no server side validation of data sent on creating/editing a discount code.
Changes proposed in this pull request: