Created
February 8, 2012 15:33
-
-
Save hassek/1770504 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sender(request): | |
if not request.is_ajax(): | |
raise Http404 | |
#import ipdb; ipdb.set_trace() | |
images = Image.objects.filter(is_available=True).order_by('last_update') | |
if images: | |
image = images[0] | |
image.is_available = False | |
image.save() | |
if not request.user.is_anonymous(): | |
UserImage(image=image, sender=request.user).save() | |
# List of functions to be executed | |
result = [] | |
result.append( | |
{'selector': '#panel', | |
'content': render_response(request, "_sender.html", dict(image=image if image else '')).content, | |
'call_function': 'change_content'} | |
) | |
return HttpResponse(simplejson.dumps(result)) | |
# ----------------------- JAVASCRIPT ---------------------- # | |
function process_callbacks(data){ | |
for(var i=0;i<data.length;i++){ | |
if($functions[data[i].call_function]) | |
$functions[data[i].call_function](data[i].selector,data[i].content); | |
else | |
alert('Error, no existe '+data[i].call_function); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment