defined Meta ordering of the Item() model in apps.dashboard.models; Item() also now returns a __str__ result; in .forms, defined a specific use-case of is_valid() method; a pair of new UTs in .tests.test_models help confirm str representation and list order of items; .test_forms now ensures the .is-invalid bootstrap class is tested as a css class attr; migrations run; full UT & FT suite back to passing state (tho a refactor of flimsy form customizations is desperately needed)
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.shortcuts import redirect, render
|
||||
from .forms import ExistingListItemForm, ItemForm
|
||||
from .models import Item, List
|
||||
|
||||
def home_page(request):
|
||||
return render(request, 'apps/dashboard/home.html', {"form": ItemForm()})
|
||||
return render(request, "apps/dashboard/home.html", {"form": ItemForm()})
|
||||
|
||||
def new_list(request):
|
||||
form = ItemForm(data=request.POST)
|
||||
if form.is_valid():
|
||||
nulist = List.objects.create()
|
||||
Item.objects.create(text=request.POST["text"], list=nulist)
|
||||
form.save(for_list=nulist)
|
||||
return redirect(nulist)
|
||||
else:
|
||||
return render(request, "apps/dashboard/home.html", {"form": form})
|
||||
@@ -24,5 +23,5 @@ def view_list(request, list_id):
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect(our_list)
|
||||
return render(request, 'apps/dashboard/list.html', {'list': our_list, "form": form})
|
||||
return render(request, "apps/dashboard/list.html", {"list": our_list, "form": form})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user