From df9ff2cce0ba1b3df57206884c2a8d1d494552d1 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 13 Oct 2010 12:03:19 +0100 Subject: [PATCH] Switch reddit posts to be a AJAX request --- hr/views.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hr/views.py b/hr/views.py index cc2c6c2..82c7ca5 100644 --- a/hr/views.py +++ b/hr/views.py @@ -88,14 +88,15 @@ def view_application(request, applicationid): else: return HttpResponseRedirect(reverse('hr.views.index')) - posts = [] - for acc in app.user.redditaccount_set.all(): - try: - accposts = acc.recent_posts() - except: - reddit_error = "Encountered a error while trying to get all Reddit posts" - accposts = [] - posts.extend(accposts) + if response.GET.has_key('redditxhr'): + posts = [] + for acc in app.user.redditaccount_set.all(): + try: + accposts = acc.recent_posts() + except: + accposts = [] + posts.extend(accposts) + return HttpResponse(simplejson.dumps(accposts), mimetype='application/javascript') return render_to_response('hr/applications/view.html', locals(), context_instance=RequestContext(request))