Skip to content

Commit

Permalink
new status support
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 20, 2016
1 parent 27a0c68 commit b4aa667
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/budy/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@

class Order(bundle.Bundle):

STATUS_S = dict(
created = "created",
paid = "paid",
sent = "sent",
received = "received",
returned = "returned",
canceled = "canceled"
)

STATUS_C = dict(
created = "grey",
paid = "blue",
sent = "blue",
received = "green",
returned = "red",
canceled = "red"
)

status = appier.field(
initial = "created",
meta = "enum",
enum = STATUS_S,
colors = STATUS_C
)

paid = appier.field(
type = bool,
initial = False
Expand Down Expand Up @@ -84,7 +109,7 @@ def __init__(self, *args, **kwargs):

@classmethod
def list_names(cls):
return ["id", "key", "currency", "total", "account"]
return ["id", "currency", "total", "account", "status"]

@classmethod
def line_cls(cls):
Expand All @@ -93,11 +118,13 @@ def line_cls(cls):
def verify(self):
appier.verify(not self.shipping_address == None)
appier.verify(not self.billing_address == None)
appier.verify(self.status == "created")
appier.verify(self.paid == False)

def pay_s(self, payment_data):
self.verify()
self._pay_stripe(payment_data)
self.status = "paid"
self.paid = True
self.save()

Expand Down

0 comments on commit b4aa667

Please sign in to comment.