cleaned up invisibles
[~kgodey/maayanwich.git] / views.py
index 2b92417..18f6ea1 100644 (file)
--- a/views.py
+++ b/views.py
@@ -11,10 +11,6 @@ import datetime
 
 
 def add_sandwich(request):
-       if Sandwich.objects.count() > 5:
-               sandwiches = Sandwich.objects.order_by('date_made')[:5]
-       else:
-               sandwiches = Sandwich.objects.order_by('date_made')
        if request.method == 'POST': # If the form has been submitted...
                form = SandwichForm(request.POST, request.FILES) # A form bound to the POST data
                if form.is_valid(): # All validation rules pass
@@ -25,6 +21,11 @@ def add_sandwich(request):
        else:
                form = SandwichForm() # An unbound form
                
+       if Sandwich.objects.count() > 5:
+               sandwiches = Sandwich.objects.order_by('date_made')[:5]
+       else:
+               sandwiches = Sandwich.objects.order_by('date_made')
+                       
        return render_to_response('sandwich.html', {'sform': form, 'sandwiches': sandwiches,})
 
 
@@ -44,7 +45,7 @@ def add_ingredient(request):
                form = IngredientForm() # An unbound form
 
        return render_to_response('ingredient.html', {'iform': form, 'sandwiches': sandwiches})
-       
+
 
 def all_sandwich(request):
        try:
@@ -57,7 +58,7 @@ def all_sandwich(request):
                raise Http404
        return render_to_response('allsandwiches.html', {'allsandwiches': allsandwiches, 'sandwiches': sandwiches})
 
-       
+
 def baseview(request):
        try:
                if Sandwich.objects.count() > 5:
@@ -69,16 +70,16 @@ def baseview(request):
        except Sandwich.DoesNotExist:
                raise Http404
        return render_to_response('base.html', {'sandwiches': sandwiches, 'all': allsandwiches,})
-       
-       
+
+
 def sandwich_month(request, year, month):
        try:
                sandwiches = Sandwich.objects.filter(date_made__month=month, date_made__year=year)
        except Sandwich.DoesNotExist:
                raise Http404
        return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
-       
-       
+
+
 def specific_sandwich(request, slug):
        try:
                s = Sandwich.objects.get(slug=slug)
@@ -114,7 +115,8 @@ def login_view(request):
        except KeyError:
                aform = AuthenticationForm()
                return render_to_response('login.html', {'aform': aform, 'sandwiches': sandwiches,})
-               
+
+
 def create_user(request):
        if Sandwich.objects.count() > 5:
                sandwiches = Sandwich.objects.order_by('date_made')[:5]