Repository: saleor/saleor

Issue:
TypeError when configuring MAX_CART_LINE_QUANTITY via environment variable
### What I'm trying to achieve
Add an item to a cart

### Steps to reproduce the problem
1. Configure MAX_CART_LINE_QUANTITY via environment variable
2. Attempt to add an item to the cart

### What I expected to happen
A new item is added to the cart

### What happened instead/how it failed
TypeError, returns status 500, item is not added to cart

```Traceback (most recent call last):
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/henry/Code/saleor/saleor/product/views.py", line 94, in product_add_to_cart
    if form.is_valid():
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/forms.py", line 183, in is_valid
    return self.is_bound and not self.errors
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/forms.py", line 384, in full_clean
    self._clean_fields()
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/forms.py", line 402, in _clean_fields
    value = field.clean(value)
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/fields.py", line 162, in clean
    self.run_validators(value)
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/forms/fields.py", line 145, in run_validators
    v(value)
  File "/home/henry/PythonVirtualenvs/saleor/lib/python3.5/site-packages/django/core/validators.py", line 325, in __call__
    if self.compare(cleaned, self.limit_value):
  File "/home/henry/PythonVirtuale

nvs/saleor/lib/python3.5/site-packages/django/core/validators.py", line 349, in compare
    return a > b
TypeError: unorderable types: int() > str()

ERROR django.server "POST /products/product-4/add/ HTTP/1.1" 500 24428 [PID:32324:Thread-17]
```
python version: 3.5.4
django version: 1.11.5
most recent upstream commit: 0ec214a3deb606a951a268f7f83e659857be4dd7

Here's how I worked around:
[integer_cart_line_quantity.patch.txt](https://github.com/mirumee/saleor/files/1587457/integer_cart_line_quantity.patch.txt)



Discussion:

Resolving patch:
diff --git a/saleor/settings.py b/saleor/settings.py
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -280,7 +280,7 @@ def get_host():
     messages.ERROR: 'danger'}
 
 LOW_STOCK_THRESHOLD = 10
-MAX_CART_LINE_QUANTITY = os.environ.get('MAX_CART_LINE_QUANTITY', 50)
+MAX_CART_LINE_QUANTITY = int(os.environ.get('MAX_CART_LINE_QUANTITY', 50))
 
 PAGINATE_BY = 16
 DASHBOARD_PAGINATE_BY = 30


Test patch: