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: handelled invalid price value in paid tickets #6604

Merged
merged 1 commit into from Nov 18, 2019

Conversation

codedsun
Copy link
Contributor

Fixes #6597

Short description of what this resolves:

Handles when price for paid ticket is null or not an instance of float value

Changes proposed in this pull request:

  • Introduced checks in schema

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

@auto-label auto-label bot added the fix label Nov 18, 2019
@codecov
Copy link

codecov bot commented Nov 18, 2019

Codecov Report

Merging #6604 into development will decrease coverage by <.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6604      +/-   ##
===============================================
- Coverage        65.03%   65.02%   -0.01%     
===============================================
  Files              296      296              
  Lines            15247    15250       +3     
===============================================
+ Hits              9916     9917       +1     
- Misses            5331     5333       +2
Impacted Files Coverage Δ
app/api/schema/tickets.py 84.81% <33.33%> (-2.04%) ⬇️

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 006110f...866da1c. Read the comment docs.

@codedsun
Copy link
Contributor Author

@iamareebjamal @prateekj117 Please check

@@ -67,6 +67,12 @@ def validate_quantity(self, data):
raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
"quantity should be greater than or equal to max-order")

@validates_schema
def validate_price(self, data):
if data['type'] == 'paid' and ('price' not in data or not isinstance(data['price'], float)):
Copy link
Member

Choose a reason for hiding this comment

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

No need to check for the data type of data['price']. Also, make sure that a paid ticket has a price > 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok! adding the check

@@ -67,6 +67,12 @@ def validate_quantity(self, data):
raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
"quantity should be greater than or equal to max-order")

@validates_schema
def validate_price(self, data):
if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):

Choose a reason for hiding this comment

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

multiple spaces after keyword

def validate_price(self, data):
if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):
raise UnprocessableEntity({'pointer': 'data/attributes/price'},
"paid ticket price should be valid")
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
"paid ticket price should be valid")
"paid ticket price should be greater than 0")

prateekj117
prateekj117 previously approved these changes Nov 18, 2019
Copy link
Member

@prateekj117 prateekj117 left a comment

Choose a reason for hiding this comment

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

@codedsun
Copy link
Contributor Author

Thanks, I made it..!

@iamareebjamal iamareebjamal merged commit 0a0e2c4 into fossasia:development Nov 18, 2019
codedsun added a commit to codedsun/open-event-server that referenced this pull request Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Ticket Type for Free Tickets
4 participants