예제 #1
0
파일: add.py 프로젝트: sadig/todo-tracker
    def handle_command(self, args=None):
        if args is None:
            raise ValueError('args can\'t be None')
        if args.sub_command == self.COMMAND_NAME:
            task = None
            task_id = 0
            if args.task_id is not None:
                try:
                    task_id = int(args.task_id)
                except ValueError as e:
                    raise ValueError('task_id is not a Number')
                try:
                    task = TaskDocument.objects.get(counter=task_id)
                except TaskDocument.DoesNotExist as e:
                    raise TaskNotFound('Task with ID \'{0}\' does not exist'.format(task_id))

                work = WorkDocument()
                work.title = args.title
                work.status = 'new'
                work.task = task
                work.created_at = datetime.datetime.utcnow()
                if args.work_start:
                    timelog = WorkTimeLog()
                    timelog.start = datetime.datetime.utcnow()
                    work.timelog.append(timelog)
                    work.status = 'started'
                work.save()
                print('Workitem \'{0}\' (ID: {1}) added.'.format(work.title, work.id))
예제 #2
0
    def handle_command(self, args=None):
        if args is None:
            raise ValueError('args can\'t be None')
        if args.sub_command == self.COMMAND_NAME:
            task = None
            task_id = 0
            if args.task_id is not None:
                try:
                    task_id = int(args.task_id)
                except ValueError as e:
                    raise ValueError('task_id is not a Number')
                try:
                    task = TaskDocument.objects.get(counter=task_id)
                except TaskDocument.DoesNotExist as e:
                    raise TaskNotFound(
                        'Task with ID \'{0}\' does not exist'.format(task_id))

                work = WorkDocument()
                work.title = args.title
                work.status = 'new'
                work.task = task
                work.created_at = datetime.datetime.utcnow()
                if args.work_start:
                    timelog = WorkTimeLog()
                    timelog.start = datetime.datetime.utcnow()
                    work.timelog.append(timelog)
                    work.status = 'started'
                work.save()
                print('Workitem \'{0}\' (ID: {1}) added.'.format(
                    work.title, work.id))
예제 #3
0
파일: start.py 프로젝트: sadig/todo-tracker
 def _check_timelog(self, workitem=None):
     if workitem is None:
         raise ValueError('workitem can\'t be None')
     if len(workitem.timelog) > 0:
         lastitem = workitem.timelog[-1]
         if lastitem.start is not None and lastitem.stop is None:
             raise WorkItemAlreadyStarted('Workitem \'{0}\' (ID: {1}) already started'.format(workitem.title, workitem.id))
     item = WorkTimeLog()
     item.start = datetime.datetime.utcnow()
     workitem.status = 'started'
     workitem.timelog.append(item)
     workitem.save()
예제 #4
0
 def _check_timelog(self, workitem=None):
     if workitem is None:
         raise ValueError('workitem can\'t be None')
     if len(workitem.timelog) > 0:
         lastitem = workitem.timelog[-1]
         if lastitem.start is not None and lastitem.stop is None:
             raise WorkItemAlreadyStarted(
                 'Workitem \'{0}\' (ID: {1}) already started'.format(
                     workitem.title, workitem.id))
     item = WorkTimeLog()
     item.start = datetime.datetime.utcnow()
     workitem.status = 'started'
     workitem.timelog.append(item)
     workitem.save()