Experimenting with tracking the real project associated with a task rather than the...
[doneit] / src / rtmilk.py
index 79686ce..0bafda1 100644 (file)
@@ -13,6 +13,16 @@ def fix_url(rturl):
 class RtMilkManager(object):
        """
        Interface with rememberthemilk.com
+
+       @todo Decide upon an interface that will end up a bit less bloated
+       @todo Add interface for task tags
+       @todo Add interface for postponing tasks (have way for UI to specify how many days to postpone?)
+       @todo Add interface for task recurrence
+       @todo Add interface for task estimate
+       @todo Add interface for task location
+       @todo Add interface for task url 
+       @todo Add interface for task notes
+       @todo Add undo support
        """
        API_KEY = '71f471f7c6ecdda6def341967686fe05'
        SECRET = '7d3248b085f7efbe'
@@ -67,9 +77,9 @@ class RtMilkManager(object):
                return locations
 
        def get_tasks_with_details(self, projId):
-               for taskSeries in self._get_taskseries(projId):
+               for realProjId, taskSeries in self._get_taskseries(projId):
                        for task in self._get_tasks(taskSeries):
-                               taskId = self._pack_ids(projId, taskSeries.id, task.id)
+                               taskId = self._pack_ids(realProjId, taskSeries.id, task.id)
                                priority = task.priority if task.priority != "N" else ""
                                yield {
                                        "id": taskId,
@@ -87,7 +97,8 @@ class RtMilkManager(object):
 
        def get_task_details(self, taskId):
                projId, seriesId, taskId = self._unpack_ids(taskId)
-               for taskSeries in self._get_taskseries(projId):
+               for realProjId, taskSeries in self._get_taskseries(projId):
+                       assert projId == realProjId, "%s != %s, looks like we let leak a metalist id when packing a task id" % (projId, realProjId)
                        curSeriesId = taskSeries.id
                        if seriesId != curSeriesId:
                                continue
@@ -97,7 +108,7 @@ class RtMilkManager(object):
                                        continue
                                return {
                                        "id": taskId,
-                                       "projId": projId,
+                                       "projId": realProjId,
                                        "name": taskSeries.name,
                                        "url": fix_url(taskSeries.url),
                                        "locationId": taskSeries.location_id,
@@ -125,7 +136,7 @@ class RtMilkManager(object):
 
        def set_project(self, taskId, newProjId):
                projId, seriesId, taskId = self._unpack_ids(taskId)
-               rsp = self._rtm.tasks.setName(
+               rsp = self._rtm.tasks.moveTo(
                        timeline=self._timeline,
                        from_list_id=projId,
                        to_list_id=newProjId,
@@ -212,6 +223,7 @@ class RtMilkManager(object):
                        rspTasksList = (rspTasksList, )
 
                for something in rspTasksList:
+                       realProjId = something.id
                        try:
                                something.taskseries
                        except AttributeError:
@@ -223,7 +235,7 @@ class RtMilkManager(object):
                                somethingsTaskseries = (something.taskseries, )
 
                        for taskSeries in somethingsTaskseries:
-                               yield taskSeries
+                               yield realProjId, taskSeries
 
        def _get_tasks(self, taskSeries):
                if isinstance(taskSeries.task, list):