- return render_to_response('onesandwich.html', {'s': s, 'sandwiches': sandwiches,})
+ return render_to_response('onesandwich.html', {'s': s, 'sandwiches': sandwiches, 'user': request.user,})
+
+def logout_view(request):
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
+ if request.user.is_authenticated():
+ logout(request)
+ thankshtml = "<p class=\"formthanks\">You have been logged out.</p>"
+ return HttpResponse(thankshtml)
+ else:
+ thankshtml = "<p class=\"formthanks\">You are not logged in.</p>"
+ return HttpResponse(thankshtml)