Пример #1
0
    def add_tasklist(self, tasklist):
        tasklist_dict = tasklist.to_str_dict()
                
        # Create a dict with only a 'title' property; it looks like everything
        # else is ignored by the GTask service insert handler.
        keywords = coggrinder.utilities.GoogleKeywords
        filtered_insert_dict = coggrinder.utilities.DictUtilities.filter_dict(tasklist_dict,
            (keywords.TITLE,))
        
        # Execute the insert operation.
        result_dict = self.service_proxy.insert(body=filtered_insert_dict).execute()

        # Convert the resulting dict (which contains assigned ID, updated values
        # from the service) back into a TaskList object.
        tasklist = TaskList.from_str_dict(result_dict)

        return tasklist
Пример #2
0
 def get_all_tasklists(self):     
     """
     Return a dictionary of all tasklists available. Dictionary keys will be
     entity IDs, values will be the corresponding tasklist instances.
     """   
     tasklist_items_dict = self.service_proxy.list().execute()
     
     assert tasklist_items_dict.has_key(coggrinder.utilities.GoogleKeywords.ITEMS)
     
     tasklist_items_list = tasklist_items_dict.get(coggrinder.utilities.GoogleKeywords.ITEMS)
     
     tasklist_result_list = dict()
     for tasklist_dict in tasklist_items_list:
         tasklist = TaskList.from_str_dict(tasklist_dict)
         
         tasklist_result_list[tasklist.entity_id] = tasklist
      
     return tasklist_result_list
Пример #3
0
    def update_tasklist(self, tasklist):
        """
        This method updates the TaskList using a patch command rather than a
        full update.
        TODO: Enhance this method to only update fields that have been locally
        modified.
        """
        tasklist_dict = tasklist.to_str_dict()
                
        # Create a dict with only the 'title' and 'id' properties.   
        keywords = coggrinder.utilities.GoogleKeywords
        filtered_update_dict = coggrinder.utilities.DictUtilities.filter_dict(tasklist_dict,
            (keywords.TITLE, keywords.ID))
        
        # Execute the update operation.
        result_dict = self.service_proxy.patch(tasklist=tasklist.entity_id,
            body=filtered_update_dict).execute()

        # Convert the resulting dict (which contains updated values  from the 
        # service) back into a TaskList object.
        tasklist = TaskList.from_str_dict(result_dict)

        return tasklist
Пример #4
0
 def get_tasklist(self, entity_id):        
     tasklist_dict = self.service_proxy.get(tasklist=entity_id).execute()
     
     tasklist = TaskList.from_str_dict(tasklist_dict)
     
     return tasklist