Fakultas Ilmu Komputer UI

Commit 158df638 authored by Yumna Pratista's avatar Yumna Pratista
Browse files

changed base.html

parent aca6abff
Pipeline #23298 failed with stages
in 6 minutes and 5 seconds
# Generated by Django 2.2.1 on 2019-10-15 07:40
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('app_homepage', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='item',
old_name='list',
new_name='list1',
),
]
# Generated by Django 2.2.1 on 2019-10-15 07:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('app_homepage', '0002_auto_20191015_1440'),
]
operations = [
migrations.RenameField(
model_name='item',
old_name='list1',
new_name='list',
),
]
......@@ -5,9 +5,13 @@
{% block form_action %}/lists/{{ list.id }}/add_item{% endblock %}
{% block table %}
<table id="id_list_table" class="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
{% if list %}
<table id="id_list_table" class="table">
{% for item in list.item_set.all %}
<tr><td>{{ forloop.counter }}: {{ item.text }}</td></tr>
{% endfor %}
</table>
{% else %}
<h3 id="id_list_table">You can't have an empty list item</h3>
{% endif %}
{% endblock %}
......@@ -8,6 +8,7 @@
<title>To-Do lists</title>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/base.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div class="container">
......@@ -15,11 +16,12 @@
<div class="row">
<div class="col-md-6 col-md-offset-3 jumbotron">
<div class="text-center">
<h1>{% block header_text %}{% endblock %}</h1>
<form method="POST" action="{% block form_action %}{% endblock %}">
<h1 class="header_text">{% block header_text %}{% endblock %}</h1>
<form id="new_item_form" class="form_baru" method="POST" action="{% block form_action %}{% endblock %}">
<input name="item_text" id="id_new_item"
class="form-control input-lg"
placeholder="Enter a to-do item" />
<div class="has-error" id="has-error"></div>
​{% csrf_token %}
</form>
</div>
......@@ -27,11 +29,31 @@
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="col-md-6 col-md-offset-3 has-error">
​{% block table %}
​{% endblock %}
</div>
</div>
</div>
</body>
<script>
$(document).ready(function() {
var input = document.getElementById("id_new_item");
input.addEventListener("keypress", function (e) {
if (e.keyCode === 13) { // 13 is enter
// code for enter
var isi_input = input.value;
e.preventDefault();
if(isi_input === ""){
document.getElementsByClassName("has-error")[0].innerHTML = "You can't have an empty list item";
document.getElementsByClassName("has-error")[0].style.display = "block";
console.log(document.getElementsByClassName("has-error")[0].value);
} else{
document.getElementById("new_item_form").submit();
}
};
});
});
</script>
</html>
\ No newline at end of file
No preview for this file type
......@@ -27,8 +27,11 @@ class FunctionalTest(StaticLiveServerTestCase):
try:
table = self.browser.find_element_by_id('id_list_table')
rows = table.find_elements_by_tag_name('tr')
self.assertIn(row_text, [row.text for row in rows])
return
if len(rows) == 0:
self.assertIn(table.text, "You can't have an empty list item")
else :
self.assertIn(row_text, [row.text for row in rows])
return
except (AssertionError, WebDriverException) as e:
if time.time() - start_time > MAX_WAIT:
raise e
......
......@@ -21,7 +21,6 @@ class ItemValidationTest(FunctionalTest):
self.browser.find_element_by_css_selector('.has-error').text,
"You can't have an empty list item"
))
# She tries again with some text for the item, which now works
self.browser.find_element_by_id('id_new_item').send_keys('Buy milk')
self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
......@@ -44,7 +43,7 @@ class ItemValidationTest(FunctionalTest):
# She tries again with some text for the item, which now works
self.fail('finish this test!')
# self.fail('finish this test!')
......
......@@ -90,6 +90,7 @@ class NewVisitorTest(FunctionalTest):
# Again, there is no trace of Edith's list
page_text = self.browser.find_element_by_tag_name('body').text
time.sleep(5)
self.assertNotIn('Buy peacock feathers', page_text)
self.assertIn('Buy milk', page_text)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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