Added a single sandwich view + url pattern.
authorKriti Godey <kriti.godey@gmail.com>
Tue, 2 Mar 2010 20:36:04 +0000 (15:36 -0500)
committerKriti Godey <kriti.godey@gmail.com>
Tue, 2 Mar 2010 20:36:04 +0000 (15:36 -0500)
templates/onesandwich.html [new file with mode: 0644]
urls.py
views.py

diff --git a/templates/onesandwich.html b/templates/onesandwich.html
new file mode 100644 (file)
index 0000000..0feaa5b
--- /dev/null
@@ -0,0 +1,17 @@
+<html>
+       <head>
+               <title>Every Ma'ayanwich Ever!</title></head>
+       <body>
+               <h3>{{ s.adjective }}</h3>
+               <p>Made on {{ s.date_made }} and added by {{ s.user.username }}.</p>
+               <img src="{{ s.picture }}">
+               <h5>Ingredients</h5>
+               <ul>
+                       {% for i in s.ingredients.all %}
+                               <li>{{ i.name }}
+                       {% endfor %}
+               </ul>
+               <h5>Notes</h5>
+               <p> {{ s.notes }}</p>
+       </body>
+</html>
\ No newline at end of file
diff --git a/urls.py b/urls.py
index 8d04d4b..a2025b8 100644 (file)
--- a/urls.py
+++ b/urls.py
@@ -7,4 +7,5 @@ urlpatterns = patterns('',
        (r'^addingredient/$', views.add_ingredient),
        (r'^allsandwiches/$', views.all_sandwich),
        (r'^newsandwiches/$', views.newsandwiches),
+       (r'^sandwich/(?P<slug>[-\w]+)/$', views.specific_sandwich),
 )
index 3b12aec..dff7b66 100644 (file)
--- a/views.py
+++ b/views.py
@@ -41,6 +41,7 @@ def all_sandwich(request):
        except Sandwich.DoesNotExist:
                raise Http404
        return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
+
        
 def newsandwiches(request):
        try:
@@ -50,4 +51,12 @@ def newsandwiches(request):
                        sandwiches = Sandwich.objects.order_by('date_made')
        except Sandwich.DoesNotExist:
                raise Http404
-       return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
\ No newline at end of file
+       return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
+       
+       
+def specific_sandwich(request, slug):
+       try:
+               sandwiches = Sandwich.objects.get(slug=slug)
+       except Sandwich.DoesNotExist:
+               raise Http404
+       return render_to_response('onesandwich.html', {'s': sandwiches,})
\ No newline at end of file