[billreminder: 7/17] Added 'category' to Bill init and fixed the example.
- From: Og B. Maciel <ogmaciel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [billreminder: 7/17] Added 'category' to Bill init and fixed the example.
- Date: Thu, 24 Feb 2011 01:55:58 +0000 (UTC)
commit e49364c2580b0f533494967e7fd783207c4a4576
Author: Luiz Armesto <luiz armesto gmail com>
Date: Mon Aug 16 00:46:30 2010 -0300
Added 'category' to Bill init and fixed the example.
src/db/entities.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/db/entities.py b/src/db/entities.py
index 7bb282b..68ca3f7 100644
--- a/src/db/entities.py
+++ b/src/db/entities.py
@@ -34,9 +34,9 @@ class Bill(Base):
catId = Column(Integer, ForeignKey('categories.id'))
category = relation(Category, backref=backref('bills', order_by=id))
- def __init__(self, payee, amount, dueDate, alarmDate=None, notes=None, paid=False, repeats=False):
+ def __init__(self, payee, amount, dueDate, alarmDate=None, notes=None, paid=False, repeats=None, category=None):
self.payee = payee
- self.amount=amount
+ self.amount = amount
self.dueDate = dueDate
if alarmDate:
self.alarmDate = alarmDate
@@ -44,6 +44,8 @@ class Bill(Base):
self.notes = notes
self.paid = paid
self.repeats = repeats
+ if category:
+ self.category = category
def __repr__(self):
return self.payee
@@ -66,7 +68,7 @@ if __name__ == 'main':
# Create a new Category record
food = Category('Groceries')
# Add category to bill
- ht.category.append(food)
+ food.bills.append(ht)
# Session to talk to the database
session = Session()
@@ -84,5 +86,5 @@ if __name__ == 'main':
print "Category: %s" % instance
# Get all Bills with a category of 'Groceries'
- for instance in session.query(Bill).filter(Bill.category.contains(food)):
+ for instance in session.query(Bill).filter(Bill.category==food):
print instance
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]