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))
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))
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()
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()