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

Prevent trying to save a negative quantity to a Basket #2000

Merged
merged 1 commit into from
Feb 10, 2016

Conversation

crgwbr
Copy link
Contributor

@crgwbr crgwbr commented Feb 10, 2016

basket.Line.quantity is a positive integer field, but the quantity sumation in
basket.Basket.add_product made it possible to try and save negative values. This
makes add_product never go below 0-quantity, thereby preventing a db exception
from being thrown. Also adds a test for the described behavior.

basket.Line.quantity is a positive integer field, but the quantity sumation in
basket.Basket.add_product made it possible to try and save negative values. This
makes add_product never go below 0-quantity, thereby preventing a db exception
from being thrown. Also adds a test for the described behavior.
@mvantellingen
Copy link
Contributor

👍

mvantellingen added a commit that referenced this pull request Feb 10, 2016
Prevent trying to save a negative quantity to a Basket
@mvantellingen mvantellingen merged commit 3989275 into django-oscar:master Feb 10, 2016
@bufke
Copy link

bufke commented Feb 19, 2016

@mvantellingen is it intentional that a 0 quantity line can exist? I've created some funky scenarios with oscar-api by using api-basket-add-product with a -1 quantity. It kind of makes sense I could use that to go from 2 to 1. Going to 1 to 0 while keeping the line is really odd. I'm unsure if this should be addressed on django-oscar or django-oscar-api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants