Commits

Zakhar Zibarov committed 726567a

fixed ajax, added 'withdrawn' field to ajax answer

Comments (0)

Files changed (1)

         if not created:
             fave.withdrawn = not fave.withdrawn
             fave.save()
-        context = "{'success': 'true', 'content_object_id': '%s'}" % (faved_object.id)
+        context = '{"success": true, "content_object_id": "%s", "withdrawn": %s}' % (faved_object.id, 'true' if fave.withdrawn else 'false')
         return HttpResponse(context, mimetype="application/json")
     else:
         raise Http404
     fave_type = FaveType.objects.get(slug=fave_type_slug)
     fave = Fave.objects.create_or_update(request.user, faved_object, fave_type, force_not_withdrawn=True)
     if request.is_ajax():
-        context = "{'success': 'true', 'content_object_id': '%s'}" % (faved_object.id)
+        context = '{"success": true, "content_object_id": "%s", "withdrawn": %s}' % (faved_object.id, 'true' if fave.withdrawn else 'false')
         return HttpResponse(context, mimetype="application/json")
     else:
         return render_to_response(success_template_name, RequestContext(request, { 'fave': fave }))
     fave_type = FaveType.objects.get(slug=fave_type_slug)
     fave = Fave.objects.withdrawl(request.user, faved_object, fave_type)
     if request.is_ajax():
-        context = "{'success': 'true', 'content_object_id': '%s'}" % (faved_object.id)
+        context = '{"success": true, "content_object_id": "%s", "withdrawn": %s}' % (faved_object.id, 'true' if fave.withdrawn else 'false')
         return HttpResponse(context, mimetype="application/json")
     else:
         return render_to_response(success_template_name, RequestContext(request, { 'fave': fave }))