Beispiel #1
0
def create(request):
	name = request.POST.get('name')

	task = Task(name=name, created_by=request.user)
	task.save()
	
	return redirect("/")
Beispiel #2
0
def create(request):
    name = request.POST.get('name')

    task = Task(name=name, created_by=request.user)
    task.save()

    return redirect("/")
Beispiel #3
0
def add_task(request):
    text = request.GET.get('text', None)
    if text:
        new_task = Task(text=text)
        new_task.save()
        return JsonResponse({"result": "ok"})

    return JsonResponse({"result": "error"})
Beispiel #4
0
    def test_tasks_sorted_by_compelted(self):
        completed = Task.create(self.user, "completed", "completed desc")
        completed.complete(self.user)
        uncompleted = Task.create(self.user, "uncompleted", "uncompleted desc")

        data = TodoData(self.user).data()

        self.assertEqual(uncompleted, data[0]["tasks"][0])
        self.assertEqual(completed, data[0]["tasks"][1])
Beispiel #5
0
 def test_reject_task(self):
     task = Task(parent_list=self.list_,
                 owner=self.user,
                 priority=Task.NORMAL)
     task.save()
     self.client.login(username="******", password="******")
     response = self.client.patch(self.url.format(self.list_.id, task.id))
     self.assertEqual(response.status_code, 202)
     task_dict = json.loads(response.content.decode("utf-8"))
     self.assertEqual(task_dict["priority"], Task.REJECTED)
Beispiel #6
0
    def test_tasks_sorted_newest(self):
        older = Task.create(self.user, "older", "older desc")
        newer = Task.create(self.user, "newer", "newer desc")
        newest = Task.create(self.user, "newest", "newest desc")

        data = TodoData(self.user).data()

        self.assertEqual(older, data[0]["tasks"][0])
        self.assertEqual(newer, data[0]["tasks"][1])
        self.assertEqual(newest, data[0]["tasks"][2])
Beispiel #7
0
    def test_users_with_no_tasks_ignored(self):
        has_tasks = User.objects.create_user("hastasks", password="******")
        no_tasks = User.objects.create_user("notasks", password="******")

        user_task = Task.create(self.user, "user_task", "desc")
        has_tasks_task = Task.create(has_tasks, "has_tasks_task", "desc")

        data = TodoData(self.user).data()

        self.assertEqual(2, len(data))
        self.assertFalse({"user": no_tasks, "tasks": []} in data)
Beispiel #8
0
    def test_update_task_wrong_user(self):
        task = Task(title="Title", parent_list=self.list_, owner=self.user)
        task.save()

        self.client.login(username="******", password="******")

        data = task.as_dict()

        response = self.client.patch(self.url.format(self.list_.id, task.id),
                                     json.dumps(data))

        self.assertEqual(response.status_code, 403)
Beispiel #9
0
def create_task():
    if not request.json or 'body' not in request.json:
        abort(400)

    task = Task(body=request.json['body'], completed=False)
    db.session.add(task)
    db.session.commit()

    return jsonify({
        'status': 'success',
        'task': task.serialize()
    }), 201
Beispiel #10
0
def saveTask(request):
	if request.POST:
		taskData = request.POST

		
		taskName = taskData['taskName']
		taskDescription = taskData['taskDesc']
		taskPriority = taskData['priority']
		taskDate = taskData['dueDate']
		taskOwner = User.objects.get(username = request.user.username)
		taskStatus = "Todo"
		newTaskObject = Task(taskName = taskName,taskDescription=taskDescription,taskDueDate = taskDate,taskPriority=taskPriority,taskOwner=taskOwner,taskStatus=taskStatus)
		newTaskObject.save()
	return HttpResponseRedirect('/todo/')
Beispiel #11
0
    def test_update_task(self):
        task = Task(title="Title", parent_list=self.list_, owner=self.user)
        task.save()

        self.client.login(username="******", password="******")

        data = task.as_dict()
        data["title"] = "Mon super titre"
        data["description"] = "Ma super nouvelle description !"
        response = self.client.patch(self.url.format(self.list_.id, task.id),
                                     json.dumps(data))
        response_json = response.json()
        self.assertEqual(response.status_code, 202)
        self.assertEqual(response_json["title"], "Mon super titre")
Beispiel #12
0
    def handle(self, *args, **kwargs):
        # Manual unpacking here since the integer values will be
        # encapsulated inside a list
        nb_todolists = kwargs['nb_todolists'][0]
        nb_subtasks = kwargs['nb_subtasks'][0]
        nb_tasks = kwargs['nb_tasks'][0]
        owner = kwargs['owner']
        todolist_names = kwargs['todolist_name']

        if todolist_names is not None and nb_todolists != len(todolist_names):
            error_msg = 'Length of todolists names and number of todolists mismatch: %d != %d'
            raise CommandError(error_msg % (len(todolist_names), nb_todolists))

        print(owner)
        owner = User.objects.get(username=owner)

        lists = [TodoList(owner=owner) for i in range(nb_todolists)]
        if todolist_names:
            for name, todolist in zip(todolist_names, lists):
                todolist.title = name
        # Insert all the lists with only one query
        TodoList.objects.bulk_create(lists)
        # Retrieve all the saved lists, this is a mandatory step since django's
        # bulk_create will NOT populate the model's primary key after insertion.
        lists = TodoList.objects.filter(title__in=todolist_names)

        tasks = []
        subtasks = []

        # First step: Create the tasks
        for todolist in lists:
            for i in range(nb_tasks):
                task = Task(owner=owner, parent_list=todolist, title=str(i))
                tasks.append(task)

        # Bulk insert the tasks
        Task.objects.bulk_create(tasks)
        # Retrieve the newly created task (see the why in line 49)
        tasks = Task.objects.filter(owner=owner)
        # Then bulk insert the subtasks, we cannot create the tasks and their
        # subtasks in the same SQL query since the subtasks will refer to their
        # parents that will no exist in the database at the time of insertion
        for task in tasks:
            for i in range(nb_subtasks):
                task = Task(owner=owner,
                            parent_list=todolist,
                            title=str(i),
                            parent_task=task)
                subtasks.append(task)
        Task.objects.bulk_create(subtasks)
Beispiel #13
0
def add_task():
    form = TaskForm(request.form)
    nowdate=datetime.now()
    if request.method == 'POST' and form.validate():
          task = Task(form.content.data,form.deadline.data)
          if not form.assign.data:
             assignlist = AssignList(user=g.user.username)
             task.assignlist.append(assignlist)
          else:
             for user in form.assign.data.split():
                 assignlist = AssignList(user=user)
                 task.assignlist.append(assignlist)
          task.save()
          return redirect('/task/pending')
    return render_template('add.html', form=form,nowdate=nowdate)
Beispiel #14
0
    def put(self, id):
        data = request.get_json()

        todoList = TodoList.get_by_id(id)

        if todoList is None:
            task_lst = []
            for task in data['tasks']:
                obj = Task(task_name=task['task_name'],
                           task_done=task['task_done'])
                task_lst.append(obj)

            todoList = TodoList(
                todoList_name=data['todoList_name'],
                todoList_done=data['todoList_done'],
            )
            todoList.tasks = task_lst

            todoList.save()

            return {'message': 'Successfully saved new data'}, 201
        else:
            todoList.todoList_name = data['todoList_name']
            todoList.todoList_done = data['todoList_done']
            for t in data['tasks']:
                task = Task.query.get(t['taskID'])
                task.task_name = t['task_name']
                task.task_done = t['task_done']

            todoList.save()
            return {'message': 'Updated data with '}
Beispiel #15
0
    def _create_task(self, request):
        user = request.user
        title = request.POST.get("title", "")
        description = request.POST.get("description", "")
        new_task = Task.create(user, title, description)

        return redirect("todo")
Beispiel #16
0
class Command(BaseCommand):
    help = 'Add users and there tasks'
    # users = [
    #     {'username': '******', "password": '******', 'tasks'
    #     : [{'title': 'Learning Django', 'description': 'Learning to Change Team', 'status': 'inprogress'}]}
    # ]
    users = [
        User(username='******',
             password='******',
             tasks=[
                 Task(title='Learning Django',
                      description='Learning to Change Team',
                      status='inprogress')
             ])
    ]

    def handle(self, *args, **options):
        for user_data in self.users:
            try:
                user = User.objects.create(username=user_data['username'],
                                           password=user_data['password'])
                user.save()
                for task_data in user_data['tasks']:
                    task = Task(title=task_data['title'],
                                description=task_data['description'],
                                status=task_data['status'],
                                user=user)
                    task.save()
            except:
                raise CommandError('Unable to create user')
            self.stdout.write(
                self.style.SUCCESS("Successfully User's data was entered"))
Beispiel #17
0
def create_task_mock(name):
    url = reverse('todo:list')
    model = Task(name=name)
    result = model_to_dict(model)
    client = APIClient()
    response = client.post(url, data=result, format="json")
    return response
Beispiel #18
0
 def handle(self, *args, **options):
     for user_data in self.users:
         try:
             user = User.objects.create(username=user_data['username'],
                                        password=user_data['password'])
             user.save()
             for task_data in user_data['tasks']:
                 task = Task(title=task_data['title'],
                             description=task_data['description'],
                             status=task_data['status'],
                             user=user)
                 task.save()
         except:
             raise CommandError('Unable to create user')
         self.stdout.write(
             self.style.SUCCESS("Successfully User's data was entered"))
Beispiel #19
0
def main():
    drop_tables()
    create_tables()

    board = Board(name='Demo Board')
    session.add(board)
    session.commit()

    for i in range(6):
        board.task_number += 1
        title = 'Example task {}'.format(string.ascii_uppercase[i])
        description = 'Description of {}'.format(title)

        if i in [0, 1, 2]:
            status = TO_DO
        elif i in [3, 4]:
            status = IN_PROGRESS
        else:
            status = DONE

        task = Task(
            number=board.task_number,
            title=title,
            description=description,
            board_id=board.id,
            status=status)
        session.add(task)
    session.commit()

    return 0
Beispiel #20
0
    def post(self, username):
        """
        Creates a new task
        """

        with self.make_session() as session:

            user = yield as_future(
                session.query(User).filter(User.username == username).first)
            if user:

                try:
                    due_date = self.data['due_date'][0]
                    completed = self.data['completed'][0]
                except KeyError:
                    due_date = None
                    completed = None

                task = Task(
                    name=self.data['name'][0],
                    note=self.data['note'][0],
                    creation_date=datetime.now(),
                    due_date=datetime.strptime(due_date, '%d/%m/%Y %H:%M:%S')
                    if due_date else None,
                    completed=completed if completed else False,
                    user_id=user.id,
                    user=user)

                session.add(task)
                self.send_response(
                    {
                        'message': 'Task created',
                        'Task': task.name
                    }, status=201)
Beispiel #21
0
def close_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    task.subtasks[subtask_id].status=True
    task.subtasks[subtask_id].endtime=datetime.now().date()
    task.save()
    return redirect('/task/pending')
    
Beispiel #22
0
def saveTask(request):
    if request.POST:
        taskData = request.POST

        taskName = taskData['taskName']
        taskDescription = taskData['taskDesc']
        taskPriority = taskData['priority']
        taskDate = taskData['dueDate']
        taskOwner = User.objects.get(username=request.user.username)
        taskStatus = "Todo"
        newTaskObject = Task(taskName=taskName,
                             taskDescription=taskDescription,
                             taskDueDate=taskDate,
                             taskPriority=taskPriority,
                             taskOwner=taskOwner,
                             taskStatus=taskStatus)
        newTaskObject.save()
    return HttpResponseRedirect('/todo/')
Beispiel #23
0
def task_create(request):
    """ Create new task view
    """
    if request.method == 'POST':
        # If the form has been submitted...
        form = TaskForm(request.POST, **{'request': request})
        # A form bound to the POST data
        print "Process the form"
        if form.is_valid():
            print("Form is valid")
            # All validation rules pass
            # Process the data in form.cleaned_data
            start_date = form.data.get('start_date')
            print start_date
            if start_date:
                start_date = datetime.datetime.strptime(start_date, '%m/%d/%Y')
            else:
                start_date = None
            due_date = form.data.get('due_date')
            if due_date:
                due_date = datetime.datetime.strptime(due_date, '%m/%d/%Y')
            else:
                due_date = None

            completed = form.data.get('completed')
            if not completed:
                completed = False

            t = Task(title=form.data.get('title'),
                     start_date=start_date,
                     due_date=due_date,
                     completed=completed,
                     todo_list_id=form.data.get('todo_list'),
                     priority=form.data.get('priority'))
            messages.success(request, 'New task successfully created')
            t.save()
            return HttpResponseRedirect(reverse('todo.views.task_list'))
        print "Form is invalid"
        message_error(form, request)
    else:
        # An unbound form
        form = TaskForm(**{'request': request})
    return render_to_response('new_task.html', {'form': form},
                              context_instance=RequestContext(request))
Beispiel #24
0
    def test_user_always_first(self):
        """
        User's list should always be first, even if they have 0 tasks and
        another user has 1+ tasks.
        """
        other_user = User.objects.create_user("other", password="******")
        task = Task.create(self.user, "user_task", "desc")

        data = TodoData(self.user).data()
        self.assertEqual(self.user, data[0]["user"])
Beispiel #25
0
def task_create(request):
    """ Create new task view
    """
    if request.method == 'POST':
        # If the form has been submitted...
        form = TaskForm(request.POST, **{'request':request})
        # A form bound to the POST data
        print "Process the form"
        if form.is_valid():
            print("Form is valid")
            # All validation rules pass
            # Process the data in form.cleaned_data
            start_date = form.data.get('start_date')
            print start_date
            if start_date:
                start_date = datetime.datetime.strptime(start_date, '%m/%d/%Y')
            else:
                start_date = None
            due_date = form.data.get('due_date')
            if due_date:
                due_date = datetime.datetime.strptime(due_date, '%m/%d/%Y')
            else:
                due_date = None

            completed = form.data.get('completed')
            if not completed:
                completed = False

            t = Task(title=form.data.get('title'), start_date=start_date,
                     due_date=due_date, completed=completed,
                     todo_list_id=form.data.get('todo_list'),
                     priority=form.data.get('priority'))
            messages.success(request, 'New task successfully created')
            t.save()
            return HttpResponseRedirect(reverse('todo.views.task_list'))
        print "Form is invalid"
        message_error(form, request)
    else:
        # An unbound form
        form = TaskForm(**{'request':request})
    return render_to_response('new_task.html', {'form': form},
                              context_instance=RequestContext(request))
Beispiel #26
0
def edit_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)
    task=Task.objects(id=ObjectId(task_id)).first()
    subtask=task.subtasks[subtask_id]
    if request.method == 'POST' and form.validate():
        form=SubTaskForm(request.form)    
        task.subtasks[subtask_id].content=form.content.data
        task.subtasks[subtask_id].deadline=form.deadline.data
        task.save()
        return redirect('/task/pending')
    return render_template('edit_sub.html', form=form, subtask=subtask,task_id=task_id,subtask_id=subtask_id)
Beispiel #27
0
 def test_delete_task(self):
     self.client.login(username="******", password="******")
     task = Task.create(self.user, "blah", "blah")
     response = self.client.post(reverse("task"), {
         "_method": "DELETE",
         "task_id": 1,
     },
                                 follow=True)
     tasks = Task.objects.all()
     self.assertEqual(0, len(tasks))
     self.assertRedirects(response, reverse("todo"))
Beispiel #28
0
def add_subtask(task_id):
    nowdate=datetime.now()
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    if request.method == 'POST' and form.validate():
        subtask = SubTask()
        form.populate_obj(subtask)
        subtask.id = ObjectId()
        task.subtasks.append(subtask)        
        task.save()
        return redirect('/task/pending')
    return render_template('add_sub.html', form=form , task_id=task_id, nowdate=nowdate)
Beispiel #29
0
 def test_edit_task_complete(self):
     self.client.login(username="******", password="******")
     task = Task.create(self.user, "blah", "blah")
     response = self.client.post(reverse("task"), {
         "_method": "PUT",
         "task_id": 1,
         "completed": "true"
     },
                                 follow=True)
     task.refresh_from_db()
     self.assertFalse(task.task_open)
     self.assertRedirects(response, reverse("todo"))
Beispiel #30
0
    def test_detail_update(self):
        name = "Foo"
        create_task_mock(name)

        name = "Bar"
        model = Task(name=name)
        result = model_to_dict(model)

        url = '/todo/1/'
        response = self.client.put(url, data=result, format="json")
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertContains(response, name)
Beispiel #31
0
def task_add(request):
    '''add task to project'''
    pid = int(request.POST.get('pid', 0))
    task = Task()
    task.name = request.POST.get('task_name')
    task.project = get_object_or_404(Project, id__exact=pid)
    priority = request.POST.get('priority')
    if priority:
        task.priority = priority
    else:
        task.priority = TASK_PRIORITY['medium']
    task.completed = 0
    task.save()
    #add project task count
    task.project.tasks += 1
    task.project.save()
    #return HttpResponseRedirect('/todo/')
    return HttpResponse('success')
Beispiel #32
0
 def test_edit_task_all(self):
     self.client.login(username="******", password="******")
     task = Task.create(self.user, "blah", "blah")
     response = self.client.post(reverse("task"), {
         "_method": "PUT",
         "task_id": 1,
         "title": "new title",
         "description": "new desc",
     },
                                 follow=True)
     task.refresh_from_db()
     self.assertEqual("new title", task.title)
     self.assertEqual("new desc", task.description)
     self.assertRedirects(response, reverse("todo"))
Beispiel #33
0
def create_task(board_id, request_body, user_id):
    """Create a task"""
    query = Board.query.filter(Board.id == board_id, Board.user_id == user_id)
    board = query.one_or_none()

    if not board:
        raise NotFoundError('Board not found.')

    board.task_number += 1
    task = Task(board_id=board_id, number=board.task_number, **request_body)
    session.add(task)
    session.commit()

    return TaskSchema().dump(task).data
Beispiel #34
0
def index(request):
    context = {"success": False, "login": False}

    if not request.user.is_authenticated:
        if request.method == "POST":
            username = request.POST['username']
            password = request.POST['password']

            user = authenticate(request, username=username, password=password)
            if user is not None:
                login(request, user)
            else:
                try:
                    user = User.objects.create_user(username=username,
                                                    password=password)
                except:
                    context = {"success": False, "login": True}

                    return render(request, 'login.html', context)
                user.save()
                login(request, user)
            return redirect("/")
        return render(request, 'login.html', context)
    if request.method == "POST":

        title = request.POST['title']
        desc = request.POST['desc']
        dat = request.POST['date']
        ins = Task(username=request.user,
                   tasktitle=title,
                   taskdesc=desc,
                   date=dat)
        ins.save()
        context = {"success": True}
        # print(title,desc)

    return render(request, 'index.html', context)
Beispiel #35
0
def task_add(request):
    '''add task to project'''
    pid = int(request.POST.get('pid',0))
    task = Task()
    task.name = request.POST.get('task_name')
    task.project = get_object_or_404(Project,id__exact = pid)
    priority = request.POST.get('priority')
    if priority:
        task.priority = priority
    else:
        task.priority = TASK_PRIORITY['medium']
    task.completed = 0
    task.save()
    #add project task count
    task.project.tasks += 1
    task.project.save()
    #return HttpResponseRedirect('/todo/')
    return HttpResponse('success')
Beispiel #36
0
    def test_users_sorted_by_number_of_tasks(self):
        user_little = User.objects.create_user("little", password="******")
        user_lots = User.objects.create_user("lots", password="******")

        Task.create(user_little, "title1", "desc1")
        Task.create(user_lots, "title2", "desc2")
        Task.create(user_lots, "title3", "desc3")

        data = TodoData(self.user).data()

        self.assertEqual(user_lots, data[1]["user"])
        self.assertEqual(user_little, data[2]["user"])
Beispiel #37
0
    def post(self):
        data = request.get_json()

        task_lst = []
        for task in data['tasks']:
            obj = Task(task_name=task['task_name'],
                       task_done=task['task_done'])
            task_lst.append(obj)

        todoList = TodoList(
            todoList_name=data['todoList_name'],
            todoList_done=data['todoList_done'],
        )
        todoList.tasks = task_lst

        todoList.save()

        return {'message': 'Successfully saved new data'}, 201
Beispiel #38
0
def post(self, username):
    """Create a new task."""
    with self.make_session() as session:
        profile = yield as_future(session.query(Profile).filter(Profile.username == username).first)
        if profile:
            due_date = self.form_data['due_date'][0]
            task = Task(
                name=self.form_data['name'][0],
                note=self.form_data['note'][0],
                creation_date=datetime.now(),
                due_date=datetime.strptime(
                    due_date, '%d/%m/%Y %H:%M:%S') if due_date else None,
                completed=self.form_data['completed'][0],
                profile_id=profile.id,
                profile=profile
            )
            session.add(task)
            self.send_response({'msg': 'posted'}, status=201)
Beispiel #39
0
def home(request):
    template_name = "todo/home.html"

    if request.method == 'POST':
        task = Task()
        task.active = True
        task.text = request.POST.get('task')
        task.todo = Todo.objects.get(pk=request.POST.get('todo_id'))
        task.save()

    todo = Todo.objects.all()[0]

    return render(request, template_name, {'todo': todo})
Beispiel #40
0
 def save(self, *args, **kwargs):
     if self.old_question1 != self.question1:
         self.editable = 'No'
         for value in self._meta.get_fields():
             if value.name.lower() in [
                     'id', 'editable', 'gm_name', 'product_type',
                     'assigned_by'
             ]:
                 pass
             else:
                 std = StandardAnswer.objects.get(
                     property_type=self.product_type,
                     question=value.verbose_name)
                 if getattr(std, "answer_choice").lower() == getattr(
                         self, value.name).lower():
                     pass
                 else:
                     Task(title=value.verbose_name,
                          task_list=TaskList.objects.get(
                              name='OPS BG TASKS'),
                          due_date=timezone.now() +
                          timedelta(days=std.task_deadline_expected),
                          created_by=User.objects.get(
                              username=self.assigned_by),
                          assigned_to=User.objects.get(
                              username=self.gm_name),
                          priority=std.priority).save()
         subject = 'BG FORM Filled by - ' + self.gm_name
         message = 'Hi ' + self.assigned_by + ',\nBG Form assigned to ' + \
                   self.gm_name + ' has benn filled at - ' + str(timezone.now()) + "\n\nFrom - Admin"
         email_from = settings.EMAIL_HOST_USER
         recipient_list = [
             User.objects.get(username=self.assigned_by).email
         ]
         send_mail(subject, message, email_from, recipient_list)
     else:
         subject = 'BG FORM Assigned by - ' + self.assigned_by
         message = 'Hi ' + self.gm_name + ',\nBG Form assigned to you by ' + \
                   self.assigned_by + "\n\nFrom - Admin"
         email_from = settings.EMAIL_HOST_USER
         recipient_list = [User.objects.get(username=self.gm_name).email]
         send_mail(subject, message, email_from, recipient_list)
     super(FormQuestions, self).save(*args, **kwargs)
Beispiel #41
0
def edit_task(task_id):
    form=TaskForm(request.form)
    task=Task.objects(id=ObjectId(task_id)).first()
    namelist=[]
    for i in task.assignlist:
        namelist.append(i.user)
    namelist=" ".join(namelist)
    if request.method == 'POST' and form.validate():
        task.content=form.content.data
        task.deadline=form.deadline.data
        task.assignlist=[]
        recipients=[]
        if not form.assign.data:
           task.assignlist.append(AssignList(user=g.user.username))
        else:
           for user in form.assign.data.split():
               if User.objects(username=user):
                   assign = AssignList(user=user)
                   task.assignlist.append(assign)
        task.save()
        
        return redirect('/task/pending')
    return render_template('edit.html', form=form, task=task,task_id=task_id,namelist=namelist)
Beispiel #42
0
def add_task_handler(request, socket, context, message):
    """
    Handler for add task on a todo
    """
    if message.get("action") == "add_task":
        todo = Todo.objects.get(pk=message.get("todo"))

        task = Task()
        task.todo = todo
        task.active = True
        task.text = message.get("task")
        task.save()

        joined = {
            "action": "new_task",
            "task": task.text,
            "task_id": task.pk,
            "active": task.active,
            "archived": task.archived,
            "todo_id": todo.pk,
        }
        socket.send_and_broadcast_channel(joined)
Beispiel #43
0
def show_finished():
    tasks=Task.objects(status=True)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_finished.html',tasks=tasks,title='Finished Tasks')
Beispiel #44
0
def show_pending():
    tasks=Task.objects(status=False)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_pending.html',tasks=tasks,title='Pending Tasks')
Beispiel #45
0
def show_timeout():
    tasks=Task.objects(deadline__lte=datetime.now(),status=False)
    for task in tasks:
        task.subtasks=enumerate(task.subtasks)
    return render_template('show_timeout.html',tasks=tasks,title='Timeout Tasks',timeout=True)
Beispiel #46
0
def delete_subtask(task_id,subtask_id):
    form=SubTaskForm(request.form)    
    task=Task.objects(id=ObjectId(task_id)).first()
    del task.subtasks[subtask_id]
    task.save()
    return redirect('/task/pending')
Beispiel #47
0
def delete_task(task_id):
    Task.objects(id=ObjectId(task_id)).first().delete()
    return redirect('/task/pending')
Beispiel #48
0
def close_task(task_id):
    task=Task.objects(id=ObjectId(task_id)).first()
    task.endtime=datetime.now()
    task.status=True
    task.save()
    return redirect('/task/pending')