Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606823475-practice
Commits
71bae416
Commit
71bae416
authored
Oct 09, 2019
by
Muhammad Ilham Peruzzi
Browse files
refactor templates to use a base template
parent
56b0e478
Changes
3
Hide whitespace changes
Inline
Side-by-side
lists/templates/base.html
0 → 100644
View file @
71bae416
<html>
<head>
<title>
To-Do lists
</title>
</head>
<body>
<h2>
Homepage
</h2>
<hr>
<div
id=
"nama_lengkap"
>
Muhammad Ilham Peruzzi
</div>
<h5>
Bio
</h5>
<div><p>
{{bio}}
</p></div>
<hr>
<h1>
{% block header_text %}{% endblock %}
</h1>
<form
method=
"POST"
action=
"{% block form_action %}{% endblock %}"
>
<input
name=
"item_text"
id=
"id_new_item"
placeholder=
"Enter a to-do item"
/>
{% csrf_token %}
</form>
{% block table %}
{% endblock %}
</body>
</html>
\ No newline at end of file
lists/templates/homepage.html
View file @
71bae416
<html>
<head>
<title>
To-Do lists
</title>
</head>
<body>
<h2>
Homepage
</h2>
<hr>
<div
id=
"nama_lengkap"
>
Muhammad Ilham Peruzzi
</div>
<h5>
Bio
</h5>
<div>
<p>
{{bio}}
</p>
</div>
<hr>
<h1>
Start a new To-Do list
</h1>
<form
method=
"POST"
action=
"/lists/new"
>
<input
name=
"item_text"
id=
"id_new_item"
placeholder=
"Enter a to-do item"
/>
{% csrf_token %}
</form>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% block header_text %}Start a new To-Do list{% endblock %}
{% block form_action %}/lists/new{% endblock %}
\ No newline at end of file
lists/templates/list.html
View file @
71bae416
<html>
<head>
<title>
To-Do lists
</title>
</head>
<body>
<h2>
Homepage
</h2>
<hr>
<div
id=
"nama_lengkap"
>
Muhammad Ilham Peruzzi
</div>
<h5>
Bio
</h5>
<div>
<p>
{{bio}}
</p>
</div>
<hr>
<h1>
Your To-Do list
</h1>
<form
method=
"POST"
action=
"/lists/{{ list.id }}/add_item"
>
<input
name=
"item_text"
id=
"id_new_item"
placeholder=
"Enter a to-do item"
/>
{% csrf_token %}
</form>
{% if list.item_set.all|length == 0 %}
{% extends 'base.html' %}
{% block header_text %}Your To-Do list{% endblock %}
{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %}
{% block table %}
{% if list.item_set.all|length == 0 %}
<p>
yey, waktunya berlibur
</p>
{% elif list.item_set.all|length
<
5
%}
<
p
>
sibuk tapi santai
</p>
{% else %}
<p>
oh tidak
</p>
{% endif %}
<table
id=
"id_list_table"
>
{% for item in list.item_set.all %}
<tr>
<td>
{{ forloop.counter }}: {{ item.text }}
</td>
</tr>
{% endfor %}
</table>
</body>
</html>
\ No newline at end of file
<table
id=
"id_list_table"
>
{% for item in list.item_set.all %}
<tr><td>
{{ forloop.counter }}: {{ item.text }}
</td></tr>
{% endfor %}
</table>
{% endblock %}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment