Fakultas Ilmu Komputer UI

Commit 7f3f78e8 authored by Rahmania Astrid Mochtar's avatar Rahmania Astrid Mochtar
Browse files

handle input and view of list title

parent 53d20d72
Pipeline #27731 passed with stages
in 8 minutes and 39 seconds
......@@ -55,9 +55,14 @@
<div class="text-center">
<h1>{% block header_text %}{% endblock %}</h1>
<form method="POST" action="{% block form_action %}{% endblock %}">
<input name="item_text" id="id_new_item"
{% block list_name_input %}{% endblock %}
​Enter todo item
<input name="item_text" id="id_new_item"
class="form-control input-lg"
placeholder="Enter a to-do item" />
placeholder="Enter a to-do item" />
<input type="submit" id="id_submit" />
​{% csrf_token %}
</form>
</div>
......
......@@ -2,4 +2,12 @@
{% block header_text %}Start a new To-Do list{% endblock %}
{% block form_action %}/lists/new{% endblock %}
\ No newline at end of file
{% block form_action %}/lists/new{% endblock %}
{% block list_name_input %}
Enter list title
<input name="list_title" id="id_new_list"
class="form-control input-lg"
placeholder="Enter a list title" />
<br />
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block header_text %}Your To-Do list{% endblock %}
{% block header_text %}Your {{ list.title }} list{% endblock %}
{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %}
......
......@@ -23,7 +23,7 @@ def view_list(request, list_id):
def new_list(request):
list_ = List.objects.create()
list_ = List.objects.create(title=request.POST['list_title'])
Item.objects.create(text=request.POST['item_text'], list=list_)
return redirect(f'/lists/{list_.id}/')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment