Esempio n. 1
0
 def test_invalid(self):
     form_data = {
         'content': '',
     }
     aboutus_form = AboutUsForm(form_data)
     self.assertFalse(aboutus_form.is_valid())
     self.assertEqual(['This field is required.'],
                      aboutus_form.errors['content'])
Esempio n. 2
0
 def test_invalid(self):
     form_data = {
         'content': '',
     }
     aboutus_form = AboutUsForm(form_data)
     self.assertFalse(aboutus_form.is_valid())
     self.assertEqual(['This field is required.'],
                      aboutus_form .errors['content'])
Esempio n. 3
0
def edit(request):
    about_us = AboutUs.objects.all()[0]
    about_form = AboutUsForm(instance=about_us)
    if request.method == "POST":
        about_form = AboutUsForm(instance=about_us, data=request.POST)
        if about_form.is_valid():
            about_form.save()
            message = "About us content successfully updated."
            messages.success(request, message)
            return HttpResponseRedirect("/about/")
    return render(request, "home/edit.html", {"about_form": about_form})
Esempio n. 4
0
def edit(request):
    about_us = AboutUs.objects.all()[0]
    about_form = AboutUsForm(instance=about_us)
    if request.method == 'POST':
        about_form = AboutUsForm(instance=about_us, data=request.POST)
        if about_form.is_valid():
            about_form.save()
            message = "About us content successfully updated."
            messages.success(request, message)
            return HttpResponseRedirect(reverse('about_page'))
    return render(request, 'home/edit.html', {'about_form': about_form})
Esempio n. 5
0
def edit(request):
    about_us = AboutUs.objects.all()[0]
    about_form = AboutUsForm(instance=about_us)
    if request.method == 'POST':
        about_form = AboutUsForm(instance=about_us, data=request.POST)
        if about_form.is_valid():
            about_form.save()
            message = "About us content successfully updated."
            messages.success(request, message)
            return HttpResponseRedirect("/about/")
    return render(request, 'home/edit.html', {'about_form': about_form})
Esempio n. 6
0
 def test_valid(self):
     form_data = {
         'content': 'description goes here',
     }
     aboutus_form = AboutUsForm(form_data)
     self.assertTrue(aboutus_form.is_valid())
Esempio n. 7
0
 def test_valid(self):
     form_data = {"content": "description goes here"}
     aboutus_form = AboutUsForm(form_data)
     self.assertTrue(aboutus_form.is_valid())
Esempio n. 8
0
 def test_invalid(self):
     form_data = {"content": ""}
     aboutus_form = AboutUsForm(form_data)
     self.assertFalse(aboutus_form.is_valid())
     self.assertEqual(["This field is required."], aboutus_form.errors["content"])