git.ithinksw.org
/
~kgodey
/
maayanwich.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1964943
)
Added a view for "top 5 sandwiches", currently using "all sandwiches" template.
author
Kriti Godey
<kriti.godey@gmail.com>
Tue, 2 Mar 2010 20:22:42 +0000
(15:22 -0500)
committer
Kriti Godey
<kriti.godey@gmail.com>
Tue, 2 Mar 2010 20:22:42 +0000
(15:22 -0500)
urls.py
patch
|
blob
|
history
views.py
patch
|
blob
|
history
diff --git
a/urls.py
b/urls.py
index
f170527
..
8d04d4b
100644
(file)
--- a/
urls.py
+++ b/
urls.py
@@
-6,4
+6,5
@@
urlpatterns = patterns('',
(r'^addsandwich/$', views.add_sandwich),
(r'^addingredient/$', views.add_ingredient),
(r'^allsandwiches/$', views.all_sandwich),
(r'^addsandwich/$', views.add_sandwich),
(r'^addingredient/$', views.add_ingredient),
(r'^allsandwiches/$', views.all_sandwich),
+ (r'^newsandwiches/$', views.newsandwiches),
)
)
diff --git
a/views.py
b/views.py
index
23f9269
..
3b12aec
100644
(file)
--- a/
views.py
+++ b/
views.py
@@
-40,4
+40,14
@@
def all_sandwich(request):
sandwiches = Sandwich.objects.all()
except Sandwich.DoesNotExist:
raise Http404
sandwiches = Sandwich.objects.all()
except Sandwich.DoesNotExist:
raise Http404
+ return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
+
+def newsandwiches(request):
+ try:
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ 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,})
\ No newline at end of file