Update org bulk accept script.
The script now:
1) leaves correctly control to the browser to update the GUI of the progress bar during ajax communication.
2) Displays an error if something went wrong (I've tried in my box stopping the server while doing the requests), and show a retry button to fetch again the list of the applications that are still not accepted and iterate over them again (seems to recover correctly restarting the server after the error in my box)
3) doesn't display any text at the beginning, and the button has the correct CSS class assigned
4) Check if there are applications to accept, if not displays a message stating that there are no orgs to accept.
Patch by: Mario Ferraro
Reviewed by: Lennard de Rijk
"""
Utility functions for handling images.
Requires PIL, as you might imagine.
"""
from django.core.files import File
class ImageFile(File):
"""
A mixin for use alongside django.core.files.base.File, which provides
additional features for dealing with images.
"""
def _get_width(self):
return self._get_image_dimensions()[0]
width = property(_get_width)
def _get_height(self):
return self._get_image_dimensions()[1]
height = property(_get_height)
def _get_image_dimensions(self):
if not hasattr(self, '_dimensions_cache'):
self._dimensions_cache = get_image_dimensions(self)
return self._dimensions_cache
def get_image_dimensions(file_or_path):
"""Returns the (width, height) of an image, given an open file or a path."""
from PIL import ImageFile as PILImageFile
p = PILImageFile.Parser()
if hasattr(file_or_path, 'read'):
file = file_or_path
else:
file = open(file_or_path, 'rb')
while 1:
data = file.read(1024)
if not data:
break
p.feed(data)
if p.image:
return p.image.size
return None