예제 #1
0
    def get_tasks(self, include_completed=True, due_min=None, due_max=None,
            task_list='@default', max_results=float('inf'), updated_min=None,
            completed_min=None, completed_max=None, include_deleted=False,
            include_hidden=False):
        params = {}
        if not include_completed:
            params['showCompleted'] = include_completed
        if due_min:
            params['dueMin'] = tc.to_date_rfc3339(due_min)
        if due_max:
            params['dueMax'] = tc.to_date_rfc3339(due_max, plus_a_min=True)
        if updated_min:
            params['updatedMin'] = tc.to_rfc3339(updated_min)
        if completed_min:
            params['completedMin'] = tc.to_rfc3339(completed_min)
        if completed_max:
            params['completedMax'] = tc.to_rfc3339(completed_max)
        if include_deleted:
            params['showDeleted'] = include_deleted
        if include_hidden:
            params['showHidden'] = include_hidden

        if task_list == '@default':
            url = Gtasks.TASKS_URL.format(task_list)
        else:
            url = Gtasks.TASKS_URL.format(self.get_list(task_list).id)
        return self._download_items(url, params, Task, self._task_index,
                max_results)
예제 #2
0
    def get_tasks(self, include_completed=True, due_min=None, due_max=None,
            task_list='@default', max_results=float('inf'), updated_min=None,
            completed_min=None, completed_max=None, include_deleted=False,
            include_hidden=False):
        params = {}
        if not include_completed:
            params['showCompleted'] = include_completed
        if due_min:
            params['dueMin'] = tc.to_date_rfc3339(due_min)
        if due_max:
            params['dueMax'] = tc.to_date_rfc3339(due_max, plus_a_min=True)
        if updated_min:
            params['updatedMin'] = tc.to_rfc3339(updated_min)
        if completed_min:
            params['completedMin'] = tc.to_rfc3339(completed_min)
        if completed_max:
            params['completedMax'] = tc.to_rfc3339(completed_max)
        if include_deleted:
            params['showDeleted'] = include_deleted
        if include_hidden:
            params['showHidden'] = include_hidden

        if task_list == '@default':
            url = Gtasks.TASKS_URL.format(task_list)
        else:
            url = Gtasks.TASKS_URL.format(self.get_list(task_list).id)
        return self._download_items(url, params, Task, self._task_index,
                max_results)
예제 #3
0
 def new_task(self, title='', due_date=None, notes='', complete=False,
         task_list='@default', completion_date=None, parent=None):
     if task_list != '@default':
         task_list = self.get_list(task_list).id
     url = Gtasks.TASKS_URL.format(task_list)
     header = {'content-type': 'application/json'}
     body = {}
     if title:
         body['title'] = title
     if due_date:
         body['due'] = tc.to_date_rfc3339(due_date)
     if notes:
         body['notes'] = notes
     if complete or completion_date:
         body['status'] = 'completed'
     if completion_date:
         body['completed'] = tc.to_rfc3339(completion_date)
     if parent:
         if type(parent) is Task:
             body['parent'] = parent._dict['id']
         elif type(parent) is str:
             body['parent'] = parent
     response = self.google.post(url, data=json.dumps(body), headers=header)
     response.raise_for_status()
     return Task(response.json(), self)
예제 #4
0
 def new_task(self, title='', due_date=None, notes='', complete=False,
         task_list='@default', completion_date=None, parent=None):
     if task_list != '@default':
         task_list = self.get_list(task_list).id
     url = Gtasks.TASKS_URL.format(task_list)
     header = {'content-type': 'application/json'}
     body = {}
     if title:
         body['title'] = title
     if due_date:
         body['due'] = tc.to_date_rfc3339(due_date)
     if notes:
         body['notes'] = notes
     if complete or completion_date:
         body['status'] = 'completed'
     if completion_date:
         body['completed'] = tc.to_rfc3339(completion_date)
     if parent:
         if type(parent) is Task:
             body['parent'] = parent._dict['id']
         elif type(parent) is str:
             body['parent'] = parent
     response = self.google.post(url, data=json.dumps(body), headers=header)
     response.raise_for_status()
     return Task(response.json(), self)
예제 #5
0
파일: task.py 프로젝트: Python3pkg/Gtasks
 def completion_date(self, value):
     if value is None:
         self._set_property('status', 'needsAction', push_override=False)
         self._set_property('completed', None)
     else:
         self._set_property('status', 'completed', push_override=False)
         self._set_property('completed', tc.to_rfc3339(value))