From: Kriti Godey Date: Fri, 12 Mar 2010 22:21:05 +0000 (-0500) Subject: added comment form plus number of comments. X-Git-Url: http://git.ithinksw.org/~kgodey/maayanwich.git/commitdiff_plain/25e2e5d9d53f08724f2fe9661265d58d850c5d17 added comment form plus number of comments. --- diff --git a/templates/allsandwiches.html b/templates/allsandwiches.html index d55cdb9..17c40df 100644 --- a/templates/allsandwiches.html +++ b/templates/allsandwiches.html @@ -14,8 +14,15 @@ {% endfor %} {% if s.notes %} -

Notes

+

Notes

{{ s.notes }}

{% endif %} + {% load comments %} + {% get_comment_count for s as c %} + {% ifequal c 1 %} +

1 comment

+ {% else %} +

{{ c }} comments

+ {% endifequal %} {% endfor %} {% endblock %} \ No newline at end of file diff --git a/templates/onesandwich.html b/templates/onesandwich.html index d685ea3..60ea42b 100644 --- a/templates/onesandwich.html +++ b/templates/onesandwich.html @@ -15,16 +15,27 @@ {% endfor %} {% if s.notes %} -

Notes

+

Notes

{{ s.notes }}

{% endif %} {% load comments %} {% get_comment_count for s as c %} -

Comments

+ {% ifequal c 1 %} +

1 Comment

+ {% else %} + {% ifequal c 0 %} +

No comments

+ {% else %} +

{{c}} Comments

+ {% endifequal %} + {% endifequal %} + {% get_comment_list for s as clist %} {% for comment in clist %}

{{ comment.user_name }} said:

{{ comment.comment }}

{{ comment.submit_date }}

{% endfor %} +

Add a Comment

+ {% render_comment_form for s %} {% endblock %} \ No newline at end of file diff --git a/views.py b/views.py index 309aa2f..39ec141 100644 --- a/views.py +++ b/views.py @@ -70,7 +70,7 @@ def add_ingredient(request): def all_sandwich(request): try: - allsandwiches = Sandwich.objects.all() + allsandwiches = Sandwich.objects.order_by('-date_made') except Sandwich.DoesNotExist: raise Http404 return render_to_response('allsandwiches.html', {'allsandwiches': allsandwiches,}, context_instance=RequestContext(request))