Fakultas Ilmu Komputer UI

Commit d3cb834b authored by Rahmania Astrid Mochtar's avatar Rahmania Astrid Mochtar
Browse files

implement list of lists display

parent 994f17dc
Pipeline #28227 failed with stages
in 4 minutes and 15 seconds
......@@ -77,6 +77,22 @@
</div>
<h5>{{ comment }}</h5>
<div class="row">
<div class="col-md-6 col-md-offset-3">
​{% for list in lists %}
{{ forloop.counter }}.
<a href="/lists/{{list.id}}">
{% if list.title %}
{{ list.title }}
{% else %}
{{ list.item_set.first.text }}
{% endif %}
</a>
<br />
{% endfor %}
</div>
</div>
</div>
</body>
<footer id="footer-name">Rahmania Astrid Mochtar</footer>
......
......@@ -5,7 +5,8 @@ from lists.models import Item, List
def home_page(request):
return render(request, 'home.html')
lists = List.objects.all()
return render(request, 'home.html', {'lists': lists})
def generate_comment(list_):
length = list_.item_set.count()
......@@ -18,8 +19,9 @@ def generate_comment(list_):
def view_list(request, list_id):
list_ = List.objects.get(id=list_id)
lists = List.objects.all()
comment = generate_comment(list_)
return render(request, 'list.html', {'list': list_, 'comment': comment })
return render(request, 'list.html', {'list': list_, 'comment': comment, 'lists': lists })
def new_list(request):
......
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