new template _partials for apps.dashboard, incl. _form.html & _scripts.html; respective form, table & content code offloaded from base.html, home.html & list.html; functional_tests.test_my_list TODO resumed (only FT not currently passing, but this is as expected)
This commit is contained in:
@@ -39,8 +39,6 @@ class MyListsTest(FunctionalTest):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return # TODO: resume here after templates refactor
|
|
||||||
|
|
||||||
self.wait_for(
|
self.wait_for(
|
||||||
lambda: self.browser.find_element(By.LINK_TEXT, "Reticulate splines")
|
lambda: self.browser.find_element(By.LINK_TEXT, "Reticulate splines")
|
||||||
)
|
)
|
||||||
|
|||||||
17
src/templates/apps/dashboard/_partials/_form.html
Normal file
17
src/templates/apps/dashboard/_partials/_form.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<form method="POST" action="{{ form_action }}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input
|
||||||
|
id="id_text"
|
||||||
|
name="text"
|
||||||
|
class="form-control form-control-lg{% if form.errors %} is-invalid{% endif %}"
|
||||||
|
placeholder="Enter a to-do item"
|
||||||
|
value="{{ form.text.value | default:'' }}"
|
||||||
|
aria-describedby="id_text_feedback"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
{% if form.errors %}
|
||||||
|
<div id="id_text_feedback" class="invalid-feedback">
|
||||||
|
{{ form.errors.text.0 }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</form>
|
||||||
6
src/templates/apps/dashboard/_partials/_scripts.html
Normal file
6
src/templates/apps/dashboard/_partials/_scripts.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<script src="/static/apps/scripts/dashboard.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = () => {
|
||||||
|
initialize("#id_text");
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -3,4 +3,11 @@
|
|||||||
{% block title_text %}Start a new to-do list{% endblock title_text %}
|
{% block title_text %}Start a new to-do list{% endblock title_text %}
|
||||||
{% block header_text %}Start a new to-do list{% endblock header_text %}
|
{% block header_text %}Start a new to-do list{% endblock header_text %}
|
||||||
|
|
||||||
{% block form_action %}{% url "new_list" %}{% endblock form_action %}
|
{% block extra_header %}
|
||||||
|
{% url "new_list" as form_action %}
|
||||||
|
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
||||||
|
{% endblock extra_header %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "apps/dashboard/_partials/_scripts.html" %}
|
||||||
|
{% endblock scripts %}
|
||||||
|
|||||||
@@ -3,13 +3,24 @@
|
|||||||
{% block title_text %}Your to-do list{% endblock title_text %}
|
{% block title_text %}Your to-do list{% endblock title_text %}
|
||||||
{% block header_text %}Your to-do list{% endblock header_text %}
|
{% block header_text %}Your to-do list{% endblock header_text %}
|
||||||
|
|
||||||
{% block form_action %}{% url "view_list" list.id %}{% endblock form_action %}
|
|
||||||
|
|
||||||
{% block table %}
|
{% block extra_header %}
|
||||||
|
{% url "view_list" list.id as form_action %}
|
||||||
|
{% include "apps/dashboard/_partials/_form.html" with form=form form_action=form_action %}
|
||||||
|
{% endblock extra_header %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-lg-6">
|
||||||
<table id="id_list_table" class="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 %}
|
||||||
</table>
|
</table>
|
||||||
{% endblock table %}
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "apps/dashboard/_partials/_scripts.html" %}
|
||||||
|
{% endblock scripts %}
|
||||||
|
|||||||
@@ -62,33 +62,13 @@
|
|||||||
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
|
<div class="row justify-content-center p-5 bg-body-tertiary rounded-3">
|
||||||
<div class="col-lg-6 text-center">
|
<div class="col-lg-6 text-center">
|
||||||
<h2 class="display-1 mb-4">{% block header_text %}{% endblock header_text %}</h2>
|
<h2 class="display-1 mb-4">{% block header_text %}{% endblock header_text %}</h2>
|
||||||
|
{% block extra_header %}
|
||||||
<form method="POST" action="{% block form_action %}{% endblock form_action %}">
|
{% endblock extra_header %}
|
||||||
{% csrf_token %}
|
|
||||||
<input
|
|
||||||
id="id_text"
|
|
||||||
name="text"
|
|
||||||
class="form-control form-control-lg{% if form.errors %} is-invalid{% endif %}"
|
|
||||||
placeholder="Enter a to-do item"
|
|
||||||
value="{{ form.text.value | default:'' }}"
|
|
||||||
aria-describedby="id_text_feedback"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
{% if form.errors %}
|
|
||||||
<div id="id_text_feedback" class="invalid-feedback">
|
|
||||||
{{ form.errors.text.0 }}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row justify-content-center">
|
{% block content %}
|
||||||
<div class="col-lg-6">
|
{% endblock content %}
|
||||||
{% block table %}
|
|
||||||
{% endblock table %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
@@ -96,12 +76,7 @@
|
|||||||
<script
|
<script
|
||||||
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/js/bootstrap.min.js"
|
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.8/js/bootstrap.min.js"
|
||||||
></script>
|
></script>
|
||||||
|
{% block scripts %}
|
||||||
<script src="/static/apps/scripts/dashboard.js"></script>
|
{% endblock scripts %}
|
||||||
<script>
|
|
||||||
window.onload = () => {
|
|
||||||
initialize("#id_text");
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user