示例#1
0
    def test_os_name_proper_chars(self):
        """ test for max length """

        # get object
        form = OsForm(data={'os_name': 'oooooooooooooooooooooooooooooo'})
        # compare
        self.assertTrue(form.is_valid())
示例#2
0
    def test_os_name_form_filled(self):
        """ test minimum form requirements / VALID """

        # get object
        form = OsForm(data={'os_name': 'os_1'})
        # compare
        self.assertTrue(form.is_valid())
示例#3
0
    def test_os_form_empty(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = OsForm(data={'os_name': ''})
        # compare
        self.assertFalse(form.is_valid())
示例#4
0
    def test_os_name_too_many_chars(self):
        """ test for max length """

        # get object
        form = OsForm(data={'os_name': 'ooooooooooooooooooooooooooooooo'})
        # compare
        self.assertFalse(form.is_valid())
示例#5
0
    def test_os_name_form_label(self):
        """ test form label """

        # get object
        form = OsForm()
        # compare
        self.assertEqual(form.fields['os_name'].label, 'Os name (*)')
示例#6
0
def oss_add(request):
    if request.method == 'POST':
        form = OsForm(request.POST)
        if form.is_valid():
            os = form.save(commit=False)
            os.save()
            os.logger(str(request.user), " OS_ADD_EXECUTED")
            messages.success(request, 'OS added')
            return redirect('/oss')
    else:
        form = OsForm()
        debug_logger(str(request.user), " OS_ADD_ENTERED")
    return render(request, 'dfirtrack_main/os/oss_add.html', {'form': form})
示例#7
0
def oss_edit(request, pk):
    os = get_object_or_404(Os, pk=pk)
    if request.method == 'POST':
        form = OsForm(request.POST, instance=os)
        if form.is_valid():
            os = form.save(commit=False)
            os.save()
            os.logger(str(request.user), " OS_EDIT_EXECUTED")
            messages.success(request, 'OS edited')
            return redirect('/oss')
    else:
        form = OsForm(instance=os)
        os.logger(str(request.user), " OS_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/os/oss_edit.html', {'form': form})
示例#8
0
def oss_add_popup(request):
    if request.method == 'POST':
        form = OsForm(request.POST)
        if form.is_valid():
            os = form.save(commit=False)
            os.save()
            os.logger(str(request.user), " OS_ADD_POPUP_EXECUTED")
            messages.success(request, 'OS added')
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')
    else:
        form = OsForm()
        debug_logger(str(request.user), " OS_ADD_POPUP_ENTERED")
    return render(request, 'dfirtrack_main/os/oss_add_popup.html',
                  {'form': form})