X-Git-Url: http://git.ithinksw.org/~kgodey/maayanwich.git/blobdiff_plain/1964943395e77b097c3a252c111a149b4d6ed2a3..2fa1060c2b4ff808834251a9e36be456b6af896f:/views.py diff --git a/views.py b/views.py index 23f9269..dff7b66 100644 --- a/views.py +++ b/views.py @@ -40,4 +40,23 @@ def all_sandwich(request): sandwiches = Sandwich.objects.all() 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 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,}) + + +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