| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Potion Store
Revision: 62
Author: andykim78
Date: 11 Dec 2007 00:38:43
Changes:Improved admin order edit interface:
Setting a line item quantity to 0 deletes the line item from the order
Changing a line item quantity regenerates the license key
| ... | ...@@ -240,8 +240,16 @@ | |
| 240 | 240 | if litem == nil |
| 241 | 241 | return false if not self.add_form_items({product_id => items[product_id]}) |
| 242 | 242 | else |
| 243 | litem.quantity = Integer(items[product_id]) | |
| 244 | litem.update | |
| 243 | quantity = Integer(items[product_id]) | |
| 244 | if quantity < 0 | |
| 245 | return false | |
| 246 | elsif quantity == 0 | |
| 247 | litem.destroy() | |
| 248 | self.line_items.delete(litem) | |
| 249 | else | |
| 250 | litem.quantity = quantity | |
| 251 | litem.update | |
| 252 | end | |
| 245 | 253 | end |
| 246 | 254 | end |
| 247 | 255 | return true |
| ... | ...@@ -1,3 +1,9 @@ | |
| 1 | 2007-12-10 Andy Kim <andy@potionfactory.com> | |
| 2 | * Improved admin order edit interface: | |
| 3 | ||
| 4 | Setting a line item quantity to 0 deletes the line item from the order | |
| 5 | Changing a line item quantity regenerates the license key | |
| 6 | ||
| 1 | 7 | 2007-12-03 Andy Kim <andy@potionfactory.com> |
| 2 | 8 | * Added instructions to config/paypal.yml |
| 3 | 9 | * Took out LF characters from config/certs/api_cert_chain.crt. I think it trips some OpenSSL insllations. |
| ... | ...@@ -7,6 +7,15 @@ | |
| 7 | 7 | validates_numericality_of :quantity |
| 8 | 8 | validates_numericality_of :unit_price |
| 9 | 9 | |
| 10 | def quantity=(qty) | |
| 11 | regenerate_keys = (self.quantity != qty) | |
| 12 | write_attribute(:quantity, qty) | |
| 13 | if regenerate_keys | |
| 14 | self.license_key = generate_license_key() | |
| 15 | save() if !new_record? | |
| 16 | end | |
| 17 | end | |
| 18 | ||
| 10 | 19 | def total |
| 11 | 20 | return round_money(quantity * self.unit_price) |
| 12 | 21 | end |