Пример #1
0
    def test_task_form_empty(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = TaskForm(data={})
        # compare
        self.assertFalse(form.is_valid())
Пример #2
0
    def test_task_tag_form_filled(self):
        """ test additional form content """

        # get object
        taskname_id = Taskname.objects.get(
            taskname_name='taskname_1').taskname_id
        # get object
        taskpriority_id = Taskpriority.objects.get(
            taskpriority_name='prio_1').taskpriority_id
        # get object
        taskstatus_id = Taskstatus.objects.get(
            taskstatus_name='taskstatus_1').taskstatus_id
        # get object
        tag_1_id = Tag.objects.get(tag_name='tag_1').tag_id
        tag_2_id = Tag.objects.get(tag_name='tag_2').tag_id
        # get object
        form = TaskForm(
            data={
                'taskname': taskname_id,
                'taskpriority': taskpriority_id,
                'taskstatus': taskstatus_id,
                'tag': [tag_1_id, tag_2_id],
            })
        # compare
        self.assertTrue(form.is_valid())
Пример #3
0
    def test_task_parent_task_form_filled(self):
        """ test additional form content """

        # get object
        taskname_id = Taskname.objects.get(
            taskname_name='taskname_1').taskname_id
        # get object
        taskpriority_id = Taskpriority.objects.get(
            taskpriority_name='prio_1').taskpriority_id
        # get object
        taskstatus_id = Taskstatus.objects.get(
            taskstatus_name='taskstatus_1').taskstatus_id
        # get object
        taskname_1 = Taskname.objects.get(taskname_name='taskname_1')
        # get object
        task_id = Task.objects.get(taskname=taskname_1).task_id
        # get object
        form = TaskForm(
            data={
                'taskname': taskname_id,
                'taskpriority': taskpriority_id,
                'taskstatus': taskstatus_id,
                'parent_task': task_id,
            })
        # compare
        self.assertTrue(form.is_valid())
Пример #4
0
    def test_task_taskname_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get object
        taskname_id = Taskname.objects.get(taskname_name='taskname_1').taskname_id
        # get object
        form = TaskForm(data = {
            'taskname': taskname_id,
        })
        # compare
        self.assertFalse(form.is_valid())
Пример #5
0
def tasks_edit(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'POST':
        form = TaskForm(request.POST, instance=task)
        if form.is_valid():
            task = form.save(commit=False)
            task.task_modified_by_user_id = request.user
            # adapt starting and finishing time corresponding to taskstatus
            if task.taskstatus == Taskstatus.objects.get(
                    taskstatus_name="Pending"):
                task.task_started_time = None
                task.task_finished_time = None
            elif task.taskstatus == Taskstatus.objects.get(
                    taskstatus_name="Working"):
                task.task_started_time = timezone.now()
                task.task_finished_time = None
            elif task.taskstatus == Taskstatus.objects.get(
                    taskstatus_name="Done"):
                task.task_finished_time = timezone.now()
                if task.task_started_time == None:
                    task.task_started_time = timezone.now()
            task.save()
            form.save_m2m()
            task.logger(str(request.user), " TASK_EDIT_EXECUTED")
            messages.success(request, 'Task edited')
            return redirect('/tasks/' + str(task.task_id))
    else:
        form = TaskForm(instance=task)
        task.logger(str(request.user), " TASK_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/task/tasks_edit.html',
                  {'form': form})
Пример #6
0
    def test_task_scheduled_time_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEquals(form.fields['task_scheduled_time'].label, 'Task scheduled time')
Пример #7
0
    def test_task_assigned_to_user_id_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEquals(form.fields['task_assigned_to_user_id'].label, 'Task assigned to user id')
Пример #8
0
    def test_task_system_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['system'].label, 'System')
Пример #9
0
    def test_task_due_time_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['task_due_time'].label, 'Task due time')
Пример #10
0
    def test_task_parent_task_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['parent_task'].label, 'Parent task')
Пример #11
0
    def test_task_taskpriority_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEquals(form.fields['taskpriority'].label, 'Taskpriority')
Пример #12
0
    def test_task_due_time_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['task_due_time'].label, 'Due (YYYY-MM-DD HH:MM:SS)')
Пример #13
0
    def test_task_taskstatus_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['taskstatus'].label, 'Taskstatus')
Пример #14
0
    def test_task_artifact_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['artifact'].label, 'Corresponding artifact')
        self.assertEqual(form.fields['artifact'].empty_label, 'Select artifact (optional)')
Пример #15
0
def tasks_add(request):
    if request.method == 'POST':
        form = TaskForm(request.POST)
        if form.is_valid():
            task = form.save(commit=False)
            task.task_created_by_user_id = request.user
            task.task_modified_by_user_id = request.user
            # adapt starting and finishing time corresponding to taskstatus
            if task.taskstatus == Taskstatus.objects.get(
                    taskstatus_name="Working"):
                task.task_started_time = timezone.now()
            elif task.taskstatus == Taskstatus.objects.get(
                    taskstatus_name="Done"):
                task.task_started_time = timezone.now()
                task.task_finished_time = timezone.now()
            task.save()
            form.save_m2m()
            task.logger(str(request.user), " TASK_ADD_EXECUTED")
            messages.success(request, 'Task added')
        if 'system' in request.GET:
            system = request.GET['system']
            return redirect('/systems/' + str(system))
        else:
            return redirect('/tasks/' + str(task.task_id))
    else:
        if request.method == 'GET' and 'system' in request.GET:
            system = request.GET['system']
            form = TaskForm(
                initial={
                    'system': system,
                    'taskpriority': 2,
                    'taskstatus': 1,
                    'task_scheduled_time': timezone.now(),
                    'task_due_time': timezone.now(),
                })
        else:
            form = TaskForm(
                initial={
                    'taskpriority': 2,
                    'taskstatus': 1,
                    'task_scheduled_time': timezone.now(),
                    'task_due_time': timezone.now(),
                })
        debug_logger(str(request.user), " TASK_ADD_ENTERED")
    return render(request, 'dfirtrack_main/task/tasks_add.html',
                  {'form': form})
Пример #16
0
    def test_task_case_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['case'].label, 'Corresponding case')
        self.assertEqual(form.fields['case'].empty_label, 'Select case (optional)')
Пример #17
0
    def test_task_system_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['system'].label, 'Corresponding system')
        self.assertEqual(form.fields['system'].empty_label, 'Select system (optional)')
Пример #18
0
    def test_task_taskname_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['taskname'].label, 'Taskname (*)')
        self.assertEqual(form.fields['taskname'].empty_label, 'Select taskname')
Пример #19
0
    def test_task_assigned_to_user_id_form_label(self):
        """ test form label """

        # get object
        form = TaskForm()
        # compare
        self.assertEqual(form.fields['task_assigned_to_user_id'].label, 'Assigned to user')
        self.assertEqual(form.fields['task_assigned_to_user_id'].empty_label, 'Select user (optional)')
Пример #20
0
    def test_task_taskstatus_form_filled(self):
        """ test minimum form requirements / VALID """

        # get object
        taskname_id = Taskname.objects.get(taskname_name='taskname_1').taskname_id
        # get object
        taskpriority_id = Taskpriority.objects.get(taskpriority_name='prio_1').taskpriority_id
        # get object
        taskstatus_id = Taskstatus.objects.get(taskstatus_name='taskstatus_1').taskstatus_id
        # get object
        form = TaskForm(data = {
            'taskname': taskname_id,
            'taskpriority': taskpriority_id,
            'taskstatus': taskstatus_id,
        })
        # compare
        self.assertTrue(form.is_valid())
Пример #21
0
    def test_task_due_time_formatcheck(self):
        """ test input format """

        # get object
        taskname_id = Taskname.objects.get(taskname_name='taskname_1').taskname_id
        # get object
        taskpriority_id = Taskpriority.objects.get(taskpriority_name='prio_1').taskpriority_id
        # get object
        taskstatus_id = Taskstatus.objects.get(taskstatus_name='taskstatus_1').taskstatus_id
        # get object
        form = TaskForm(data = {
            'taskname': taskname_id,
            'taskpriority': taskpriority_id,
            'taskstatus': taskstatus_id,
            'task_due_time': 'wrong format',
        })
        # compare
        self.assertFalse(form.is_valid())
Пример #22
0
    def test_task_assigned_to_user_id_form_filled(self):
        """ test additional form content """

        # get object
        taskname_id = Taskname.objects.get(taskname_name='taskname_1').taskname_id
        # get object
        taskpriority_id = Taskpriority.objects.get(taskpriority_name='prio_1').taskpriority_id
        # get object
        taskstatus_id = Taskstatus.objects.get(taskstatus_name='taskstatus_1').taskstatus_id
        # get user
        test_user_id = User.objects.get(username='******').id
        # get object
        form = TaskForm(data = {
            'taskname': taskname_id,
            'taskpriority': taskpriority_id,
            'taskstatus': taskstatus_id,
            'task_assigned_to_user_id': test_user_id,
        })
        # compare
        self.assertTrue(form.is_valid())
Пример #23
0
def tasks_edit(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'POST':
        form = TaskForm(request.POST, instance=task)
        if form.is_valid():
            task = form.save(commit=False)
            task.task_modified_by_user_id = request.user
            task.save()
            form.save_m2m()
            task.logger(str(request.user), " TASK_EDIT_EXECUTED")
            messages.success(request, 'Task edited')
            return redirect('/tasks/' + str(task.task_id))
    else:
        form = TaskForm(instance=task)
        task.logger(str(request.user), " TASK_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/task/tasks_edit.html',
                  {'form': form})