Ejemplo n.º 1
0
  def addTodo(self, data, todo_type = 'todo'):
    todo = Todo(data)
    next_id = self.getNextId()
    if todo_type == 'todo':
      todo.setDone(False)
    elif todo_type == 'done':
      todo.setDone()
      todo.setCompletedDate(time.strftime('%Y-%m-%d'))
    self.data['todos'][next_id] = todo
    self.data['ids'].append(next_id)

    if 'context' not in data:
      todo.setContext('default')

    if 'tracks_id' not in data:
      todo.setTracksId(None)

    if todo.getContext() not in self.data['contexts']:
      self.addContext(todo.getContext())
    self.data['contexts'][data['context']].append(next_id)

    if 'project' not in data:
      data['project'] = 'default'

    if data['project'] not in self.data['projects']:
      self.addProject(data['project'])
    self.data['projects'][data['project']].append(next_id)
Ejemplo n.º 2
0
    def addTodo(self, data, todo_type='todo'):
        todo = Todo(data)
        next_id = self.getNextId()
        if todo_type == 'todo':
            todo.setDone(False)
        elif todo_type == 'done':
            todo.setDone()
            todo.setCompletedDate(time.strftime('%Y-%m-%d'))
        self.data['todos'][next_id] = todo
        self.data['ids'].append(next_id)

        if 'context' not in data:
            todo.setContext('default')

        if 'tracks_id' not in data:
            todo.setTracksId(None)

        if todo.getContext() not in self.data['contexts']:
            self.addContext(todo.getContext())
        self.data['contexts'][data['context']].append(next_id)

        if 'project' not in data:
            data['project'] = 'default'

        if data['project'] not in self.data['projects']:
            self.addProject(data['project'])
        self.data['projects'][data['project']].append(next_id)
Ejemplo n.º 3
0
  def addTodo(self, data, todo_type = 'todo'):
    todo = Todo(data)
    # Replace spaces to underscores to avoid todo.txt limitation
    if data['project']:
      data['project'] = data['project'].replace(' ','_')
    if data['context']:
      data['context'] = data['context'].replace(' ','_')
    next_id = self.getNextId()
    if todo_type == 'todo':
      todo.setDone(False)
    elif todo_type == 'done':
      todo.setDone()
      todo.setCompletedDate(time.strftime('%Y-%m-%d'))
    self.data['todos'][next_id] = todo
    self.data['ids'].append(next_id)

    if 'context' not in data:
      todo.setContext('default')

    if 'tracks_id' not in data:
      todo.setTracksId(None)

    # Replace spaces to underscores to avoid todo.txt limitation
    if todo.getContext().replace(' ','_') not in self.data['contexts']:
      self.addContext(todo.getContext().replace(' ','_'))
    self.data['contexts'][data['context']].append(next_id)

    if 'project' not in data:
      data['project'] = 'default'

    if data['project'] not in self.data['projects']:
      self.addProject(data['project'])
    self.data['projects'][data['project']].append(next_id)
Ejemplo n.º 4
0
    def addTodo(self, data, todo_type='todo'):
        todo = Todo(data)
        next_id = self.getNextId()
        if todo_type == 'todo':
            todo.setDone(False)
        elif todo_type == 'done':
            todo.setDone()
            todo.setCompletedDate(time.strftime('%Y-%m-%d'))
        if 'context' not in data:
            todo.setContext('default')
        else:
            # Replace spaces to underscores to avoid todo.txt limitation
            todo.setContext(data['context'].replace(' ', '_'))
        if 'tracks_id' not in data:
            todo.setTracksId(None)
        if 'project' not in data:
            todo.setProject('default')
            # Replace spaces to underscores to avoid todo.txt limitation
        else:
            todo.setProject(data['project'].replace(' ', '_'))

        # Tracks uses combined date and time for due or created date-time. Example: 2016-08-28T00:00:00+02:00
        # but we will use date only for local todo
        if 'due' in data:
            todo.setDueDate(data['due'].split('T')[0])
        if 'created' in data:
            todo.setCreationDate(data['created'].split('T')[0])
        if 'threshold' in data:
            todo.setThreshold(data['threshold'].split('T')[0])

        # Add parsed element to the list of todos
        self.data['todos'][next_id] = todo
        self.data['ids'].append(next_id)

        if todo.getContext() not in self.data['contexts']:
            self.addContext(todo.getContext())
        self.data['contexts'][data['context']].append(next_id)

        if data['project'] not in self.data['projects']:
            self.addProject(data['project'])
        self.data['projects'][data['project']].append(next_id)