[hamster-applet] more bug fixes
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] more bug fixes
- Date: Tue, 13 Apr 2010 15:11:03 +0000 (UTC)
commit 70a4c68347fd350478a9a00f924354ed1958ecce
Author: Toms Bauģis <toms baugis gmail com>
Date: Tue Apr 13 16:10:56 2010 +0100
more bug fixes
src/hamster/client.py | 6 +++++-
src/hamster/db.py | 16 ++++++++++------
src/hamster/storage.py | 9 ++++++---
3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/hamster/client.py b/src/hamster/client.py
index 49292f9..2abcf69 100644
--- a/src/hamster/client.py
+++ b/src/hamster/client.py
@@ -118,7 +118,7 @@ class Storage(object):
return from_dbus_fact(self.conn.GetFact(id))
def add_fact(self, activity_name, tags, start_time = None, end_time = 0,
- category_name = '', description = ''):
+ category_name = None, description = None):
if start_time:
start_time = timegm(start_time).timetuple()
@@ -130,6 +130,9 @@ class Storage(object):
else:
end_time = 0
+ category_name = category_name or ''
+ description = description or ''
+
return self.conn.AddFact(activity_name, tags, start_time, end_time, category_name, description)
def touch_fact(self, fact, end_time = None):
@@ -192,4 +195,5 @@ class Storage(object):
return self.conn.GetCategoryByName(category)
def get_activity_by_name(self, activity, category_id = None, ressurect = True):
+ category_id = category_id or 0
return self.conn.GetActivityByName(activity, category_id, ressurect)
diff --git a/src/hamster/db.py b/src/hamster/db.py
index 907d4f3..349dea2 100644
--- a/src/hamster/db.py
+++ b/src/hamster/db.py
@@ -279,10 +279,14 @@ class Storage(storage.Storage):
res = self.fetchone(query, (_("Unsorted"), name, ))
if res:
+ res = dict(res)
+ res['deleted'] = res['deleted'] or False
+
# if the activity was marked as deleted, ressurect on first call
# and put in the unsorted category
if res['deleted'] and not ressurect:
return None
+
elif res['deleted']:
update = """
UPDATE activities
@@ -450,7 +454,7 @@ class Storage(storage.Storage):
SET end_time = ?
WHERE id = ?""", (start_time, fact["id"]))
fact_name = fact["name"]
- new_fact = self.__add_fact(fact["name"],
+ new_fact_id = self.__add_fact(fact["name"],
"", # will create tags in the next step
end_time,
fact["end_time"],
@@ -460,7 +464,7 @@ class Storage(storage.Storage):
SELECT ?, tag_id
FROM fact_tags
WHERE fact_id = ?"""
- self.execute(tag_update, (new_fact["id"], fact["id"])) #clone tags
+ self.execute(tag_update, (new_fact_id, fact["id"])) #clone tags
#eliminate
elif fact["end_time"] and \
@@ -489,7 +493,7 @@ class Storage(storage.Storage):
# make sure that we do have an activity name after parsing
if not activity.activity_name:
- return
+ return 0
# explicitly stated takes precedence
activity.description = description or activity.description
@@ -526,7 +530,7 @@ class Storage(storage.Storage):
if not start_time or not activity.activity_name: # sanity check
- return
+ return 0
# now check if maybe there is also a category
category_id = None
@@ -560,7 +564,7 @@ class Storage(storage.Storage):
if previous["activity_id"] == activity_id \
and previous["tags"] == sorted([tag["name"] for tag in tags]) \
and previous["description"] == (description or ""):
- return previous
+ return previous["id"]
# otherwise, if no description is added
# see if maybe it is too short to qualify as an activity
@@ -583,7 +587,7 @@ class Storage(storage.Storage):
"""
self.execute(update, (before["id"],))
- return before
+ return before["id"]
else:
# otherwise stop
update = """
diff --git a/src/hamster/storage.py b/src/hamster/storage.py
index 3816ed8..0ee37f5 100644
--- a/src/hamster/storage.py
+++ b/src/hamster/storage.py
@@ -335,10 +335,13 @@ class Storage(dbus.service.Object):
@dbus.service.method("org.gnome.Hamster", in_signature='sib', out_signature='a{sv}')
- def GetActivityByName(self, activity, category_id = None, ressurect = True):
- return dict(self.__get_activity_by_name(activity, category_id, ressurect))
-
+ def GetActivityByName(self, activity, category_id, ressurect = True):
+ category_id = category_id or None
+ if activity:
+ return dict(self.__get_activity_by_name(activity, category_id, ressurect))
+ else:
+ return {}
# tags
@dbus.service.method("org.gnome.Hamster", in_signature='b', out_signature='aa{sv}')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]