easy_thumbnails.fields: 22 total statements, 0.0% covered

Generated: Wed 2013-03-13 10:33 CET

Source file: /media/Envs/Envs/filer-gallery/lib/python2.7/site-packages/easy_thumbnails/fields.py

Stats: 0 executed, 18 missed, 4 excluded, 41 ignored

  1. from django.db.models.fields.files import FileField, ImageField
  2. from easy_thumbnails import files
  3. class ThumbnailerField(FileField):
  4. """
  5. A file field which provides easier access for retrieving (and generating)
  6. thumbnails.
  7. To use a different file storage for thumbnails, provide the
  8. ``thumbnail_storage`` keyword argument.
  9. """
  10. attr_class = files.ThumbnailerFieldFile
  11. def __init__(self, *args, **kwargs):
  12. # Arguments not explicitly defined so that the normal ImageField
  13. # positional arguments can be used.
  14. self.thumbnail_storage = kwargs.pop('thumbnail_storage', None)
  15. super(ThumbnailerField, self).__init__(*args, **kwargs)
  16. def south_field_triple(self):
  17. """
  18. Return a suitable description of this field for South.
  19. """
  20. from south.modelsinspector import introspector
  21. field_class = 'django.db.models.fields.files.FileField'
  22. args, kwargs = introspector(self)
  23. return (field_class, args, kwargs)
  24. class ThumbnailerImageField(ThumbnailerField, ImageField):
  25. """
  26. An image field which provides easier access for retrieving (and generating)
  27. thumbnails.
  28. To use a different file storage for thumbnails, provide the
  29. ``thumbnail_storage`` keyword argument.
  30. To thumbnail the original source image before saving, provide the
  31. ``resize_source`` keyword argument, passing it a usual thumbnail option
  32. dictionary. For example::
  33. ThumbnailerImageField(
  34. ..., resize_source=dict(size=(100, 100), sharpen=True))
  35. """
  36. attr_class = files.ThumbnailerImageFieldFile
  37. def __init__(self, *args, **kwargs):
  38. # Arguments not explicitly defined so that the normal ImageField
  39. # positional arguments can be used.
  40. self.resize_source = kwargs.pop('resize_source', None)
  41. super(ThumbnailerImageField, self).__init__(*args, **kwargs)
  42. def south_field_triple(self):
  43. """
  44. Return a suitable description of this field for South.
  45. """
  46. from south.modelsinspector import introspector
  47. field_class = 'django.db.models.fields.files.ImageField'
  48. args, kwargs = introspector(self)
  49. return (field_class, args, kwargs)