Beispiel #1
0
def coveys_matrix_page(request, tasklist_to_show_id=None):
    user_mail = request.session['user_mail']

    if tasklist_to_show_id:
        tasklist = TaskList.objects.get(id=tasklist_to_show_id)
        tasks = SimpleTask.get_tasks_from_tasklist(tasklist)
    else:
        tasks = SimpleTask.get_all_tasks_by_user(user_mail)

    backlog_tasks = SimpleTask.get_matrix_backlog_tasks(tasks)

    backlog_obj = BuildTemplateContext('all', backlog_tasks)
    final_backlog = backlog_obj.get_data()

    all_user_tasks = SimpleTask.get_all_tasks_by_user(user_mail)

    matrix_obj = BuildTemplateContext('matrix', all_user_tasks)
    matrix_data = matrix_obj.get_data()

    all_tasklists = TaskList.get_tasklists_from_user(user_mail)

    final_backlog['all_tasklists'] = all_tasklists

    return render(request, "stephen_covey_matrix.html", {
        'backlog': final_backlog,
        'matrix_data': matrix_data
    })
Beispiel #2
0
 def test_get_important_tasks_with_all_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     important_tasks = SimpleTask.get_important_tasks(all_tasks)
     for task in important_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.is_important)
         self.assertEquals(task.tasklist.user, self.user)
Beispiel #3
0
 def test_get_finished_tasks_with_all_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     finished_tasks = SimpleTask.get_finished_tasks(all_tasks)
     for task in finished_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.is_done)
         self.assertEquals(task.tasklist.user, self.user)
Beispiel #4
0
 def test_get_no_date_tasks_with_all_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     no_date_tasks = SimpleTask.get_no_date_tasks(all_tasks)
     for task in no_date_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.due_date is None)
         self.assertEquals(task.tasklist.user, self.user)
Beispiel #5
0
def kanbanpage(request, tasklist_to_show_id=None):
    user_mail = request.session['user_mail']

    if tasklist_to_show_id:
        tasklist = TaskList.objects.get(id=tasklist_to_show_id)
        tasks = SimpleTask.get_tasks_from_tasklist(tasklist)
    else:
        tasks = SimpleTask.get_all_tasks_by_user(user_mail)

    initial_backlog = SimpleTask.get_kanban_backlog_tasks(tasks)

    data_dict_obj = BuildTemplateContext('all', initial_backlog)

    final_backlog = data_dict_obj.get_data()

    all_tasklists = TaskList.get_tasklists_from_user(user_mail)

    final_backlog['all_tasklists'] = all_tasklists

    in_progress = SimpleTask.objects.filter(tasklist__user__email=user_mail,
                                            in_progress=True)

    finished = SimpleTask.objects.filter(tasklist__user__email=user_mail,
                                         in_progress=False,
                                         is_done=True)

    context = {"backlog": final_backlog,
               "in_progress": in_progress,
               "finished": finished}

    return render(request, "kanban.html", context)
Beispiel #6
0
def dashboardpage(request):
    user = User.objects.get(email=request.session['user_mail'])
    all_tasks = SimpleTask.get_all_tasks_by_user(user).count()
    done_tasks = SimpleTask.get_all_done_tasks_by_user(user).count()

    today = date.today()
    next_week = today + datetime.timedelta(days=7)

    today_done_tasks = SimpleTask.objects.filter(tasklist__user=user,
                                                 due_date=today,
                                                 is_done=True).count()

    today_total_tasks = SimpleTask.objects.filter(tasklist__user=user,
                                                  due_date=today).count()

    total_until_next_week = SimpleTask.objects.filter(
        tasklist__user=user, due_date__range=(today, next_week)).count()

    done_for_next_week = SimpleTask.objects.filter(
        tasklist__user=user, is_done=True,
        due_date__range=(today, next_week)).count()

    context = {
        'all_tasks': all_tasks,
        'done_tasks': done_tasks,
        'today_done_tasks': today_done_tasks,
        'today_total_tasks': today_total_tasks,
        'total_until_next_week': total_until_next_week,
        'done_for_next_week': done_for_next_week
    }

    return render(request, "dashboard.html", context)
Beispiel #7
0
 def test_get_overdue_tasks_with_all_tasks_by_user(self):
     today = date.today()
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     overdue_tasks = SimpleTask.get_overdue_tasks(all_tasks)
     for task in overdue_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.due_date < today)
         self.assertEquals(task.tasklist.user, self.user)
Beispiel #8
0
 def test_get_matrix_backlog_tasks_with_all_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     tasks = SimpleTask.get_matrix_backlog_tasks(all_tasks)
     for task in tasks:
         self.assertFalse(task.is_done)
         self.assertEquals(task.tasklist.user, self.user)
         self.assertTrue((task.is_urgent not in [True, False])
                         and (task.is_important not in [True, False]))
Beispiel #9
0
 def test_get_future_tasks_with_all_tasks_by_user(self):
     tomorrow = date.today() + datetime.timedelta(days=1)
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     future_tasks = SimpleTask.get_future_tasks(all_tasks)
     for task in future_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.due_date > tomorrow)
         self.assertEquals(task.tasklist.user, self.user)
Beispiel #10
0
def tasks_dashboard(request, tasklist_to_show_id=None, display='all'):

    user_mail = request.session['user_mail']
    if tasklist_to_show_id:
        tasklist = TaskList.get_tasklist_by_id(id=tasklist_to_show_id)
        tasks = SimpleTask.get_tasks_from_tasklist(tasklist)
    else:
        tasks = SimpleTask.get_all_tasks_by_user(user_mail)

    data_dict_obj = BuildTemplateContext(display, tasks)

    data_dict = data_dict_obj.get_data()

    all_tasklists = TaskList.get_tasklists_from_user(user_mail)

    data_dict['all_tasklists'] = all_tasklists

    if tasklist_to_show_id:
        data_dict['tasklist_to_show'] = tasklist

    return render(request, "tasks.html", data_dict)
Beispiel #11
0
 def test_get_all_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_tasks_by_user(self.user)
     self.assertEquals(len(all_tasks), 10)
     for task in all_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertEquals(task.tasklist.user, self.user)