added comment form plus number of comments.
authorKriti Godey <kriti.godey@gmail.com>
Fri, 12 Mar 2010 22:21:05 +0000 (17:21 -0500)
committerKriti Godey <kriti.godey@gmail.com>
Fri, 12 Mar 2010 22:21:05 +0000 (17:21 -0500)
templates/allsandwiches.html
templates/onesandwich.html
views.py

index d55cdb9..17c40df 100644 (file)
                                {% endfor %}
                        </ul>
                        {% if s.notes %}
-                               <h4 class="sandwichsub">Notes</h5>
+                               <h4 class="sandwichsub">Notes</h4>
                                <p class="sandnotes"> {{ s.notes }}</p>
                        {% endif %}
+                       {% load comments %}
+                       {% get_comment_count for s as c %}
+                       {% ifequal c 1 %}
+                               <p class="sandnotes"><a href="{{ s.get_absolute_url }}">1 comment</a></p>
+                       {% else %}
+                               <p class="sandnotes"><a href="{{ s.get_absolute_url }}">{{ c }} comments</a></p>
+                       {% endifequal %}
                {% endfor %}
 {% endblock %}
\ No newline at end of file
index d685ea3..60ea42b 100644 (file)
                {% endfor %}
        </ul>
        {% if s.notes %}
-               <h4 class="sandwichsub">Notes</h5>
+               <h4 class="sandwichsub">Notes</h4>
                <p class="sandnotes"> {{ s.notes }}</p>
        {% endif %}
        {% load comments %}
        {% get_comment_count for s as c %}
-       <h4 class="sandwichsub">Comments</h5>
+       {% ifequal c 1 %}
+                       <h4 class="sandwichsub">1 Comment</h4>
+       {% else %}
+               {% ifequal c 0 %}
+                       <p class="sandnotes"><b>No comments</b></p>
+               {% else %}
+                       <h4 class="sandwichsub">{{c}} Comments</h4>
+               {% endifequal %}
+       {% endifequal %}
+
        {% get_comment_list for s as clist %}
        {% for comment in clist %}
                <p class="comment_user">{{ comment.user_name }} said:</p>
                <p class="sandnotes">{{ comment.comment }}</p>
                <p class="metadata">{{ comment.submit_date }}</p>
        {% endfor %}
+       <h4 class="addcomment">Add a Comment</h4>
+       {% render_comment_form for s %}
 {% endblock %}
\ No newline at end of file
index 309aa2f..39ec141 100644 (file)
--- 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))