bootstrap libraries added via cdn js & css script & link tags; some bootstrap styling added to base.html & list.html; unit tests updated to accomodate html parsing in assertContains() library fns (but n.b., not all unit tests have been updated to accomodate bootstrap attrs, so some still fail); all FTs currently passing from last commit

This commit is contained in:
Disco DeDisco
2026-01-03 20:05:41 -05:00
parent 8955d51474
commit 08305532c2
3 changed files with 45 additions and 11 deletions

View File

@@ -9,7 +9,11 @@ class HomePageTest(TestCase):
def test_renders_input_form(self): def test_renders_input_form(self):
response = self.client.get('/') response = self.client.get('/')
self.assertContains(response, '<form method="POST" action="/apps/dashboard/newlist">') self.assertContains(response, '<form method="POST" action="/apps/dashboard/newlist">')
self.assertContains(response, '<input name="item_text"') self.assertContains(
response,
'<input name="item_text" id="id-new-item" placeholder="Enter a to-do item" />',
html=True,
)
class ListAndItemModelsTest(TestCase): class ListAndItemModelsTest(TestCase):
def test_saving_and_retrieving_items(self): def test_saving_and_retrieving_items(self):
@@ -52,7 +56,11 @@ class DashViewTest(TestCase):
response, response,
f'<form method="POST" action="/apps/dashboard/{mylist.id}/add-item">', f'<form method="POST" action="/apps/dashboard/{mylist.id}/add-item">',
) )
self.assertContains(response, '<input name="item_text"') self.assertContains(
response,
'<input name="item_text" id="id-new-item" placeholder="Enter a to-do item" />',
html=True,
)
def test_displays_only_items_for_that_list(self): def test_displays_only_items_for_that_list(self):
# Given/Arrange # Given/Arrange

View File

@@ -6,7 +6,7 @@
{% block form_action %}/apps/dashboard/{{ list.id }}/add-item{% endblock form_action %} {% block form_action %}/apps/dashboard/{{ list.id }}/add-item{% endblock form_action %}
{% block table %} {% block table %}
<table id="id-list-table"> <table id="id-list-table" class="table">
{% for item in list.item_set.all %} {% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}. {{ item.text }}</td></tr> <tr><td>{{ forloop.counter }}. {{ item.text }}</td></tr>
{% endfor %} {% endfor %}

View File

@@ -1,19 +1,45 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en" data-bs-theme="dark">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Disco DeDisco"> <meta name="author" content="Disco DeDisco">
<meta name="robots" content="noindex, nofollow"> <meta name="robots" content="noindex, nofollow">
<title>Dashboard | {% block title_text %}{% endblock title_text %}</title> <title>Dashboard | {% block title_text %}{% endblock title_text %}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/css/bootstrap.min.css"/>
</head> </head>
<body> <body>
<h1>Dashboard | {% block header_text %}{% endblock header_text %}</h1> <div class="container">
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
<div class="col-lg-6 text-center">
<h1 class="display-1 mb-4">Dashboard | {% block header_text %}{% endblock header_text %}</h1>
<form method="POST" action="{% block form_action %}{% endblock form_action %}"> <form method="POST" action="{% block form_action %}{% endblock form_action %}">
<input name="item_text" id="id-new-item" placeholder="Enter a to-do item"> <input
name="item_text"
id="id-new-item"
class="form-control form-control-lg"
placeholder="Enter a to-do item"
/>
{% csrf_token %} {% csrf_token %}
</form> </form>
</div>
</div>
<div class="row justify-content-center">
<div class="col-lg-6">
{% block table %} {% block table %}
{% endblock table %} {% endblock table %}
</div>
</div>
</div>
</body> </body>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/js/bootstrap.min.js"
></script>
</html> </html>