X-Git-Url: http://git.ithinksw.org/~kgodey/maayanwich.git/blobdiff_plain/598bab51785e33f0f224d0603b260a9ae35cac47..21a5b5aafd25a996530e2575b32fca7a0ccac30d:/views.py diff --git a/views.py b/views.py index 309aa2f..d653118 100644 --- a/views.py +++ b/views.py @@ -6,6 +6,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from models import Sandwich, Ingredient from django.contrib.auth import authenticate, login, logout from django.contrib.auth.forms import AuthenticationForm +from django.contrib.comments.models import Comment from django.template import RequestContext from django.core import serializers from slugify import SlugifyUniquely @@ -70,7 +71,7 @@ def add_ingredient(request): def all_sandwich(request): try: - allsandwiches = Sandwich.objects.all() + allsandwiches = Sandwich.objects.order_by('-date_made') except Sandwich.DoesNotExist: raise Http404 return render_to_response('allsandwiches.html', {'allsandwiches': allsandwiches,}, context_instance=RequestContext(request)) @@ -193,6 +194,15 @@ def create_user(request): else: form = NewUserForm() # An unbound form return render_to_response('newuser.html', {'cform': form,}, context_instance=RequestContext(request)) + + +def comment_posted(request): + if request.GET['c']: + comment_id = request.GET['c'] + com = Comment.objects.get( pk = comment_id ) + post = com.content_object + if post: + return HttpResponseRedirect( post.get_absolute_url() + '#comments' ) def ajaxfun(request):