- return render_to_response("picture/picture_viewer.html", locals(),
- context_instance=RequestContext(request))
+ return render_to_response("picture/picture_viewer.html", {
+ 'picture': picture,
+ 'sponsors': sponsors,
+ }, context_instance=RequestContext(request))
+
+
+@ajax(method='get')
+def picture_page(request, key=None):
+ pictures = Picture.objects.order_by('-id')
+ if key is not None:
+ pictures = pictures.filter(id__lt=key)
+ pictures = pictures[:settings.PICTURE_PAGE_SIZE]
+ picture_data = [
+ {
+ 'id': picture.id,
+ 'title': picture.title,
+ 'author': picture.author_unicode(),
+ 'image_url': picture.image_file.url,
+ 'width': picture.width,
+ 'height': picture.height,
+ }
+ for picture in pictures
+ ]
+ return {
+ 'pictures': picture_data,
+ 'count': Picture.objects.count(),
+ }