def test_serviceprovider_form_empty(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = ServiceproviderForm(data={})
        # compare
        self.assertFalse(form.is_valid())
Esempio n. 2
0
    def test_serviceprovider_name_too_many_chars(self):
        """ test for max length """

        # get object
        form = ServiceproviderForm(data = {'serviceprovider_name': 'sssssssssssssssssssssssssssssssssssssssssssssssssss'})
        # compare
        self.assertFalse(form.is_valid())
    def test_serviceprovider_name_proper_chars(self):
        """test for max length"""

        # get object
        form = ServiceproviderForm(data={'serviceprovider_name': 's' * 50})
        # compare
        self.assertTrue(form.is_valid())
    def test_serviceprovider_name_form_filled(self):
        """ test minimum form requirements / VALID """

        # get object
        form = ServiceproviderForm(data={
            'serviceprovider_name': 'serviceprovider_1',
        })
        # compare
        self.assertTrue(form.is_valid())
Esempio n. 5
0
    def test_serviceprovider_note_form_filled(self):
        """ test additional form content """

        # get object
        form = ServiceproviderForm(data = {
            'serviceprovider_name': 'serviceprovider_1',
            'serviceprovider_note': 'lorem ipsum',
        })
        # compare
        self.assertTrue(form.is_valid())
Esempio n. 6
0
    def test_serviceprovider_name_form_label(self):
        """ test form label """

        # get object
        form = ServiceproviderForm()
        # compare
        self.assertEquals(form.fields['serviceprovider_name'].label, 'Serviceprovider name (*)')
Esempio n. 7
0
def serviceproviders_add(request):
    if request.method == 'POST':
        form = ServiceproviderForm(request.POST)
        if form.is_valid():
            serviceprovider = form.save(commit=False)
            serviceprovider.save()
            serviceprovider.logger(str(request.user),
                                   " SERVICEPROVIDER_ADD_EXECUTED")
            messages.success(request, 'Serviceprovider added')
            return redirect('/serviceproviders')
    else:
        form = ServiceproviderForm()
        debug_logger(str(request.user), " SERVICEPROVIDER_ADD_ENTERED")
    return render(request,
                  'dfirtrack_main/serviceprovider/serviceproviders_add.html',
                  {'form': form})
Esempio n. 8
0
def serviceproviders_edit(request, pk):
    serviceprovider = get_object_or_404(Serviceprovider, pk=pk)
    if request.method == 'POST':
        form = ServiceproviderForm(request.POST, instance=serviceprovider)
        if form.is_valid():
            serviceprovider = form.save(commit=False)
            serviceprovider.save()
            serviceprovider.logger(str(request.user),
                                   " SERVICEPROVIDER_EDIT_EXECUTED")
            messages.success(request, 'Serviceprovider edited')
            return redirect('/serviceproviders')
    else:
        form = ServiceproviderForm(instance=serviceprovider)
        serviceprovider.logger(str(request.user),
                               " SERVICEPROVIDER_EDIT_ENTERED")
    return render(request,
                  'dfirtrack_main/serviceprovider/serviceproviders_edit.html',
                  {'form': form})
Esempio n. 9
0
def serviceproviders_add_popup(request):
    if request.method == 'POST':
        form = ServiceproviderForm(request.POST)
        if form.is_valid():
            serviceprovider = form.save(commit=False)
            serviceprovider.save()
            serviceprovider.logger(str(request.user),
                                   " SERVICEPROVIDER_ADD_POPUP_EXECUTED")
            messages.success(request, 'Serviceprovider added')
            return HttpResponse(
                '<script type="text/javascript">window.close();</script>')
    else:
        form = ServiceproviderForm()
        debug_logger(str(request.user), " SERVICEPROVIDER_ADD_POPUP_ENTERED")
    return render(
        request,
        'dfirtrack_main/serviceprovider/serviceproviders_add_popup.html',
        {'form': form})