Ejemplo n.º 1
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)
Ejemplo n.º 2
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
    })
Ejemplo n.º 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)
Ejemplo n.º 4
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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 7
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)
Ejemplo n.º 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]))
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
def set_finished(request):
    id = request.POST['task_id']
    task = SimpleTask.get_task_with_id(id)
    task.in_progress = False
    task.is_done = True
    task.save()
    return kanbanpage(request)
Ejemplo n.º 11
0
def retire_task_from_matrix(request):
    id = request.POST['task_id']
    task = SimpleTask.get_task_with_id(id)
    task.is_important = None
    task.is_urgent = None
    task.save()
    return coveys_matrix_page(request)
Ejemplo n.º 12
0
 def test_get_no_date_tasks_with_tasks_from_tasklist(self):
     tasklist_tasks = SimpleTask.objects.filter(tasklist=self.tasklist_2)
     no_date_tasks = SimpleTask.get_no_date_tasks(tasklist_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)
Ejemplo n.º 13
0
 def test_get_important_tasks_with_tasks_from_tasklist(self):
     tasklist_tasks = SimpleTask.objects.filter(tasklist=self.tasklist_1)
     important_tasks = SimpleTask.get_important_tasks(tasklist_tasks)
     for task in important_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.is_important)
         self.assertEquals(task.tasklist.user, self.user)
Ejemplo n.º 14
0
 def test_get_matrix_backlog_tasks_with_tasks_from_tasklist(self):
     tasklist_tasks = SimpleTask.objects.filter(tasklist=self.tasklist_2)
     tasks = SimpleTask.get_matrix_backlog_tasks(tasklist_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]))
Ejemplo n.º 15
0
 def test_get_today_tasks_with_tasks_from_tasklist(self):
     today = date.today()
     tasklist_tasks = SimpleTask.objects.filter(tasklist=self.tasklist_2)
     today_tasks = SimpleTask.get_today_tasks(tasklist_tasks)
     for task in today_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.due_date == today)
         self.assertEquals(task.tasklist.user, self.user)
Ejemplo n.º 16
0
 def test_get_future_tasks_with_tasks_from_tasklist(self):
     tomorrow = date.today() + datetime.timedelta(days=1)
     tasklist_tasks = SimpleTask.objects.filter(tasklist=self.tasklist_1)
     future_tasks = SimpleTask.get_future_tasks(tasklist_tasks)
     for task in future_tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertTrue(task.due_date > tomorrow)
         self.assertEquals(task.tasklist.user, self.user)
Ejemplo n.º 17
0
def change_task_state(request):
    id = request.POST['task_id']
    task = SimpleTask.get_task_with_id(id)
    task.is_done = not task.is_done
    task.save()
    if 'tasklist_to_show_id' in request.session:
        id = request.session['tasklist_to_show_id']
    else:
        id = None
    return tasks_dashboard(request, tasklist_to_show_id=id)
Ejemplo n.º 18
0
def edit_task(request, id):
    task = SimpleTask.get_task_with_id(id=id)
    data = {
        "task_name": task.name,
        "task_id": task.id,
        "category_name": task.tasklist.name,
        "category_color": task.tasklist.color,
        "due_date": task.due_date,
        "description": task.description
    }
    return JsonResponse(data)
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
def addtask(request):
    task_name = request.POST['name']
    due_date = request.POST['due_date']
    description = request.POST['description']
    tasklist_id = request.POST['tasklists']
    importance = request.POST['importance']
    emergency = request.POST['emergency']

    user_tasklist = TaskList.get_tasklist_by_id(id=tasklist_id)

    if not due_date:
        due_date = None
    task = SimpleTask(tasklist=user_tasklist,
                      name=task_name,
                      due_date=due_date,
                      description=description,
                      creation=timezone.now(),
                      is_important=importance,
                      is_urgent=emergency)
    if task.due_date:
        task.due_date_clean_display = convert_to_clean_date(task.due_date)

    task.save()
    return tasks_dashboard(request, tasklist_to_show_id=user_tasklist.id)
Ejemplo n.º 21
0
def update_task(request):
    id = request.POST['task_id']
    task = SimpleTask.get_task_with_id(id)
    task.name = request.POST['name']
    task.due_date = request.POST['due_date']
    task.is_important = request.POST['importance']
    task.is_urgent = request.POST['emergency']

    if len(str(task.due_date)) > 5:
        task.due_date_clean_display = convert_to_clean_date(task.due_date)
        task.due_date = convert_into_date_type(str(task.due_date))
    else:
        task.due_date = None
        task.due_date_clean_display = None

    task.description = request.POST['description']
    new_category_id = request.POST['tasklists']
    new_tasklist = TaskList.get_tasklist_by_id(new_category_id)
    task.tasklist = new_tasklist
    task.save()
    return tasks_dashboard(request, tasklist_to_show_id=new_tasklist.id)
Ejemplo n.º 22
0
def update_matrix_task(request):
    id = request.POST['task_id']
    dest = request.POST['destination']
    task = SimpleTask.get_task_with_id(id)

    if dest == 'top-left':
        task.is_important = True
        task.is_urgent = True

    elif dest == 'top-right':
        task.is_important = True
        task.is_urgent = False

    elif dest == 'bottom-left':
        task.is_important = False
        task.is_urgent = True

    elif dest == 'bottom-right':
        task.is_important = False
        task.is_urgent = False

    task.save()
    return coveys_matrix_page(request)
Ejemplo n.º 23
0
 def test_get_tasks_with_due_date_from_tasklist(self):
     tasks = SimpleTask.get_tasks_with_due_date_from_tasklist(
         self.tasklist_1)
     for task in tasks:
         self.assertTrue(isinstance(task.due_date, date))
         self.assertEquals(task.tasklist.user, self.user)
Ejemplo n.º 24
0
def deltask(request):
    id = request.POST['task_id']
    SimpleTask.get_task_with_id(id).delete()
    return tasks_dashboard(request)
Ejemplo n.º 25
0
def cancel_in_progress(request):
    id = request.POST['task_id']
    task = SimpleTask.get_task_with_id(id)
    task.in_progress = False
    task.save()
    return kanbanpage(request)
Ejemplo n.º 26
0
 def test_get_tasks_from_tasklist(self):
     tasks = SimpleTask.get_tasks_from_tasklist(self.tasklist_1)
     for task in tasks:
         self.assertTrue(isinstance(task, SimpleTask))
         self.assertEquals(task.tasklist, self.tasklist_1)
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
    def get_data(self):
        overdue_tasks = SimpleTask.get_overdue_tasks(self.tasks)
        due_today_tasks = SimpleTask.get_today_tasks(self.tasks)
        due_tommorow_tasks = SimpleTask.get_tomorrow_tasks(self.tasks)
        future_tasks = SimpleTask.get_future_tasks(self.tasks)
        no_date_tasks = SimpleTask.get_no_date_tasks(self.tasks)
        finished_tasks = SimpleTask.get_finished_tasks(self.tasks)
        urgent_tasks = SimpleTask.get_urgent_tasks(self.tasks)
        important_tasks = SimpleTask.get_important_tasks(self.tasks)

        important_urgent = SimpleTask.get_important_urgent_tasks(self.tasks)
        important_non_urgent = SimpleTask.get_important_non_urgent_tasks(
            self.tasks)
        non_important_urgent = SimpleTask.get_non_important_urgent_tasks(
            self.tasks)
        non_important_non_urgent = SimpleTask. \
            get_non_important_non_urgent_tasks(self.tasks)

        matrix_backlog = SimpleTask.get_matrix_backlog_tasks(self.tasks)

        all_data = {
            'overdue_tasks': overdue_tasks,
            'due_today_tasks': due_today_tasks,
            'due_tommorow_tasks': due_tommorow_tasks,
            'future_tasks': future_tasks,
            'no_date_tasks': no_date_tasks,
            'finished_tasks': finished_tasks,
            'urgent_tasks': urgent_tasks,
            'important_tasks': important_tasks,
            'important_urgent': important_urgent,
            'important_non_urgent': important_non_urgent,
            'non_important_urgent': non_important_urgent,
            'non_important_non_urgent': non_important_non_urgent,
            'matrix_backlog': matrix_backlog
        }

        dict = {}
        keys_list = self.__content_to_return()

        for k, v in all_data.items():
            if k in keys_list:
                dict[k] = v

        return dict
Ejemplo n.º 29
0
 def test_get_task_with_id(self):
     first_task = SimpleTask.objects.all()[:1]
     task = SimpleTask.get_task_with_id(first_task[0].id)
     self.assertTrue(isinstance(task, SimpleTask))
     self.assertEquals(task.id, first_task[0].id)
Ejemplo n.º 30
0
 def test_get_all_undone_tasks_by_user(self):
     all_tasks = SimpleTask.get_all_undone_tasks_by_user(self.user)
     for task in all_tasks:
         self.assertFalse(task.is_done)
         self.assertEquals(task.tasklist.user, self.user)