Ejemplo n.º 1
0
class ThumbnailModel(models.Model):
    """creates a thumbnail resized to maximum size to fit a 100x75 area"""
    image = StdImageField(
        upload_to=UploadTo(name='image', path='img'),
        blank=True,
        variations={'thumbnail': (100, 75)}
    )
Ejemplo n.º 2
0
class ForceMinSizeModel(models.Model):
    """creates a thumbnail resized to maximum size to fit a 100x75 area"""
    image = StdImageField(
        upload_to=UploadTo(name='image', path='img'),
        force_min_size=True,
        variations={'thumbnail': (600, 600)}
    )
Ejemplo n.º 3
0
class MyStorageModel(CustomManagerModel):
    """delays creation of 150x150 thumbnails until it is called manually"""
    image = StdImageField(
        upload_to=UploadTo(name='image', path='img'),
        variations={'thumbnail': (150, 150, True)},
        storage=FileSystemStorage(),
    )
Ejemplo n.º 4
0
class CustomRenderVariationsModel(models.Model):
    """Use custom render_variations."""

    image = StdImageField(
        upload_to=UploadTo(name='image', path='img'),
        variations={'thumbnail': (150, 150)},
        render_variations=custom_render_variations,
    )
Ejemplo n.º 5
0
class ResizeModel(models.Model):
    """resizes image to maximum size to fit a 640x480 area"""
    image = StdImageField(
        upload_to=UploadTo(name='image', path='img'),
        variations={
            'medium': {'width': 400, 'height': 400},
            'thumbnail': (100, 75),
        }
    )
Ejemplo n.º 6
0
class UtilVariationsModel(models.Model):
    """delays creation of 150x150 thumbnails until it is called manually"""
    image = StdImageField(upload_to=UploadTo(name='image', path='img'),
                          variations={'thumbnail': (150, 150, True)},
                          render_variations=render_job)
Ejemplo n.º 7
0
class MinSizeModel(models.Model):
    image = StdImageField(upload_to=UploadTo(name='image', path='img'),
                          validators=[MinSizeValidator(200, 200)])
Ejemplo n.º 8
0
class MaxSizeModel(models.Model):
    image = StdImageField(upload_to=UploadTo(name='image', path='img'),
                          validators=[MaxSizeValidator(16, 16)])
Ejemplo n.º 9
0
class ResizeCropModel(models.Model):
    """resizes image to 640x480 cropping if necessary"""
    image = StdImageField(upload_to=UploadTo(name='image', path='img'),
                          variations={'thumbnail': (150, 150, True)})
Ejemplo n.º 10
0
class AdminDeleteModel(models.Model):
    """can be deleted through admin"""
    image = StdImageField(upload_to=UploadTo(name='image', path='img'),
                          blank=True)
Ejemplo n.º 11
0
 def test_file_name_kwargs(self):
     file_name = UploadTo(path='/foo', name='bar',
                          ext='.BAZ')(object(), '/path/to/file')
     assert file_name == '/foo/bar.baz'
Ejemplo n.º 12
0
 def test_file_name_no_ext(self):
     file_name = UploadTo()(object(), '/path/to/file')
     assert file_name == '/path/to/file'
Ejemplo n.º 13
0
 def test_file_name_lower(self):
     file_name = UploadTo()(object(), '/path/To/File.JPEG')
     assert file_name == '/path/to/file.jpeg'
Ejemplo n.º 14
0
 def test_file_name(self):
     file_name = UploadTo()(object(), '/path/to/file.jpeg')
     assert file_name == '/path/to/file.jpeg'