its working now but i dont like the relationship
order shouldn't have to know about his purchases purchases should know their order! purchases would be accessible by calling order.purchase_set()
This commit is contained in:
parent
4f37807ef1
commit
70a0536de1
|
@ -48,6 +48,7 @@ class Order(models.Model):
|
||||||
def addItems(self, items):
|
def addItems(self, items):
|
||||||
for item in items:
|
for item in items:
|
||||||
self.purchase.add(item)
|
self.purchase.add(item)
|
||||||
|
self.price += item.price
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "Price %s, User %s" % (self.price, self.user)
|
return "Price %s, User %s" % (self.price, self.user)
|
||||||
|
@ -58,7 +59,7 @@ class Purchase(models.Model):
|
||||||
buyable = models.ForeignKey(Buyable)
|
buyable = models.ForeignKey(Buyable)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%s%s, %s by %s" % (self.buyable.name, self.isDeposit and " (deposit)" or "", self.price, self.user)
|
return "%s%s, %s" % (self.buyable.name, self.isDeposit and " (deposit)" or "", self.price)
|
||||||
|
|
||||||
# def save(self, *args, **kwargs):
|
# def save(self, *args, **kwargs):
|
||||||
# profile = self.user.get_profile()
|
# profile = self.user.get_profile()
|
||||||
|
|
BIN
k4ever/k4ever.db
BIN
k4ever/k4ever.db
Binary file not shown.
Loading…
Reference in New Issue