[billreminder] Finally fixed toggling paid/unpaid for bills.



commit 001369f483f7ee63bbd5379c5b9df6f5a0629a44
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Fri Nov 13 12:40:56 2009 -0500

    Finally fixed toggling paid/unpaid for bills.

 src/gui/maindialog.py |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 135e88d..a9b4766 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -421,19 +421,22 @@ class MainDialog:
 
     def toggle_bill_paid(self):
         try:
+            # Fetch record from database
+            record = self.actions.get_bills(id=self.currentrecord.id)[0]
             # Toggle paid field
-            paidBill = self.currentrecord
-            paidBill.paid = paidBill.paid == 0 and 1 or 0
-            import epdb; epdb.st()
+            record.paid = record.paid == False and True or False
+
             try:
                 # Edit bill in the database
-                rec = self.actions.add_bill(paidBill)
+                transaction = self.actions.add_bill(record)
             except Exception, e:
                 print "Failed to edit bill's payment status: %s" % str(e)
+                print "Transaction: %s" % transaction
 
-            paidBill = self.actions.get_bills(id = paidBill.id)
+            # Update our current copy
+            self.currentrecord = self.actions.get_bills(id = self.currentrecord.id)[0]
             # Update timeline widget to reflect change
-            self._bullet_cache[paidBill.dueDate] = [paidBill]
+            self._bullet_cache[self.currentrecord.dueDate] = [self.currentrecord]
             # Update list with updated record
             idx = self.list.get_cursor()[0][0]
             self.update_statusbar(idx)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]