Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow item quantities to be saved to CheddarGetter

  • Loading branch information...
commit 12aba73f1e923f55ec6abd78ffed3e8bcbd6c18b 1 parent 868ed42
Ryan Showalter authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 pycheddar/__init__.py
View
13 pycheddar/__init__.py
@@ -576,8 +576,9 @@ def get_item(self, item_code):
"""Retrieve an item by item code. If the item does not exist,
raise ValueError."""
- for item in self.items:
+ for item in self.subscription.items:
if item.code == item_code:
+ item.customer = self
return item
raise ValueError, 'Item not found.'
@@ -761,7 +762,7 @@ def validate(self):
raise ValidationError otherwise."""
# sanity check: I can only modify this item if it's directly attached
- # to the cuastomer
+ # to the customer
if not hasattr(self, 'customer'):
raise ValidationError, 'Items may only have their quantity altered if they are directly attached to a customer.'
@@ -782,7 +783,13 @@ def save(self):
self.validate()
# okay, save to CheddarGetter
- xml = CheddarGetter.request('/customers/set-item-quantity/', product_code = self._product_code, item_code = self.code, code = self.customer.code)
+ xml = CheddarGetter.request(
+ '/customers/set-item-quantity/',
+ product_code=self._product_code,
+ item_code=self.code,
+ code=self.customer.code,
+ quantity=self.quantity)
+
self._load_data_from_xml(xml)
return self
Please sign in to comment.
Something went wrong with that request. Please try again.