[billreminder] some code refactoring for the add_bills and add_categories method; Now use the add method regardless



commit 6aed4abfdf83702ed0458b5b9c4e515596f9b91d
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Fri Nov 13 13:12:51 2009 -0500

    some code refactoring for the add_bills and add_categories method; Now use the add method regardless of what db object you're trying to add.

 src/daemon/dbus_manager.py  |    4 ++--
 src/gui/categoriesdialog.py |    2 +-
 src/gui/maindialog.py       |    6 +++---
 src/lib/actions.py          |    5 +----
 4 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/daemon/dbus_manager.py b/src/daemon/dbus_manager.py
index 9a5e05a..84175b7 100644
--- a/src/daemon/dbus_manager.py
+++ b/src/daemon/dbus_manager.py
@@ -118,7 +118,7 @@ class Server(dbus.service.Object):
     @dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
     def add_bill(self, kwargs):
         """ Add a record to the database """
-        ret = self.actions.add_bill(kwargs)
+        ret = self.actions.add(kwargs)
         if ret:
             self.bill_added(kwargs)
         return force_string(ret)
@@ -158,7 +158,7 @@ class Server(dbus.service.Object):
     @dbus.service.method(common.DBUS_INTERFACE, in_signature='a{ss}', out_signature='a{ss}')
     def add_category(self, kwargs):
         """ Add a record to the database """
-        ret = self.actions.add_category(kwargs)
+        ret = self.actions.add(kwargs)
         return force_string(ret)
 
     @dbus.service.method(common.DBUS_INTERFACE, in_signature='i', out_signature='b')
diff --git a/src/gui/categoriesdialog.py b/src/gui/categoriesdialog.py
index 30038cb..b58bfd7 100644
--- a/src/gui/categoriesdialog.py
+++ b/src/gui/categoriesdialog.py
@@ -222,7 +222,7 @@ class CategoriesDialog(gtk.Dialog):
         # We're adding a new category.
         else:
             cat = Category(name, color)
-            row = self.actions.add_category(cat)
+            row = self.actions.add(cat)
             # Update our local "copy" directly from database
             self.currentrecord = self.actions.get_categories(name=name)[0]
 
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 26f2e0f..93866f9 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -384,7 +384,7 @@ class MainDialog:
         if records:
             # Add new bill to database
             for rec in records:
-                bill = self.actions.add_bill(rec)
+                bill = self.actions.add(rec)
                 if bill:
                     self.list.add(self.format_row(bill))
             self.update_statusbar()
@@ -401,7 +401,7 @@ class MainDialog:
             for rec in records:
                 try:
                     # Edit bill to database
-                    rec = self.actions.add_bill(rec)
+                    rec = self.actions.add(rec)
                 except Exception, e:
                     print str(e)
             # Reload records tree (something changed)
@@ -428,7 +428,7 @@ class MainDialog:
 
             try:
                 # Edit bill in the database
-                transaction = self.actions.add_bill(record)
+                transaction = self.actions.add(record)
             except Exception, e:
                 print "Failed to edit bill's payment status: %s" % str(e)
                 print "Transaction: %s" % transaction
diff --git a/src/lib/actions.py b/src/lib/actions.py
index b71afc5..734d7b5 100644
--- a/src/lib/actions.py
+++ b/src/lib/actions.py
@@ -124,12 +124,9 @@ class Actions(object):
 
         return records
 
-    def add_bill(self, bill):
+    def add(self, dbobject):
         return self.dal.add(bill)
 
-    def add_category(self, category):
-        return self.dal.add(category)
-
     def edit(self, dbobject):
         return self.dal.add(dbobject)
 



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