[billreminder] Allow for querying of bills based on (optional) paid status; load category correctly when editing ex



commit 9fe3fc1971b225777b47f1290f30f9e40d268557
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Sat Nov 14 15:58:12 2009 -0500

    Allow for querying of bills based on (optional) paid status; load category correctly when editing existing bill; call the new edit method in the db layer object (work in progress)

 src/gui/adddialog.py  |   13 +++++++++++--
 src/gui/maindialog.py |    5 +++--
 src/lib/actions.py    |    4 +++-
 3 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/src/gui/adddialog.py b/src/gui/adddialog.py
index 426cbea..ccf3d52 100644
--- a/src/gui/adddialog.py
+++ b/src/gui/adddialog.py
@@ -271,7 +271,8 @@ class AddDialog(gtk.Dialog):
 
         if self.currentrecord.category:
             actions = Actions()
-            records = actions.get_categories(id=self.currentrecord.category[0])
+            cat_name = self.currentrecord.category[0].name
+            records = actions.get_categories(name=cat_name)
             if records:
                 categoryname = records[0].name
                 utils.select_combo_text(self.category, categoryname, 1)
@@ -466,6 +467,8 @@ class AddDialog(gtk.Dialog):
             self.endDate.set_sensitive(True)
 
     def _on_categoriesbutton_clicked(self, button, new=False):
+        category = None
+
         # if new == True, a simpler categories dialog pops up
         categories = CategoriesDialog(parent=self, new=new)
         ret = categories.run()
@@ -477,9 +480,15 @@ class AddDialog(gtk.Dialog):
                 categories._on_savebutton_clicked(None)
             category = categories.currentrecord
 
+        categories.destroy()
+
+        # Always re-populate the categories dropdown widget, regardless if
+        # newer category was added. If something was returned, select it.
+        if category:
             self._populate_category(category.name)
+        else:
+            self._populate_category()
 
-        categories.destroy()
         return ret
 
     def _on_categorycombo_changed(self, combobox):
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 7d08c19..ca2885f 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -246,6 +246,7 @@ class MainDialog:
     def reloadTreeView(self, *arg):
         # Update list with updated record
         status = self.gconf_client.get_int(GCONF_GUI_PATH + 'show_paid_bills')
+        print "Status is: %s" % status
 
         #month = self.timeline.value.month
         #year = self.timeline.value.year
@@ -401,7 +402,7 @@ class MainDialog:
             for rec in records:
                 try:
                     # Edit bill to database
-                    rec = self.actions.add(rec)
+                    rec = self.actions.edit(rec)
                 except Exception, e:
                     print str(e)
             # Reload records tree (something changed)
@@ -601,13 +602,13 @@ class MainDialog:
             self.gconf_client.set_bool(GCONF_GUI_PATH + "show_toolbar", False)
 
     def reloadTimeline(self, *args):
-        print 'reloadtimeline'
         self._bullet_cache = {}
         self.timeline.refresh()
 
     def on_timeline_cb(self, date, display_type):
         # TODO: Improve tooltip
         # TODO: Improve cache
+
         if not date in self._bullet_cache.keys():
             self._bullet_cache[date] = self.actions.get_bills(dueDate=date)
 
diff --git a/src/lib/actions.py b/src/lib/actions.py
index 7df0f79..8ace98e 100644
--- a/src/lib/actions.py
+++ b/src/lib/actions.py
@@ -27,6 +27,8 @@ class Actions(object):
 
         records = []
 
+        paid = bool(paid) if (paid and paid < 2) else None
+
         try:
             session = self.dal.Session()
             q = session.query(Bill).options(eagerload('category')).filter(Bill.dueDate >= start).filter(Bill.dueDate <= end)
@@ -128,7 +130,7 @@ class Actions(object):
         return self.dal.add(dbobject)
 
     def edit(self, dbobject):
-        return self.dal.add(dbobject)
+        return self.dal.edit(dbobject)
 
     def delete(self, dbobject):
         return self.dal.delete(dbobject)



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