mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Make sure image files has a name associated.
The generate image command will run into issues if the ImageSpecField does not have any image file source associated wit hti. Like a Optional image field. So we can not generate the images for that. So this should check to make sure that it has one.
This commit is contained in:
parent
5bb41bdccd
commit
2f7bfe5dc7
1 changed files with 10 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
import re
|
||||
from ...registry import generator_registry, cachefile_registry
|
||||
from ...exceptions import MissingSource
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
@ -22,14 +23,15 @@ well as "a:b" and "a:b:c".""")
|
|||
|
||||
for generator_id in generators:
|
||||
self.stdout.write('Validating generator: %s\n' % generator_id)
|
||||
for file in cachefile_registry.get(generator_id):
|
||||
self.stdout.write(' %s\n' % file)
|
||||
try:
|
||||
# TODO: Allow other validation actions through command option
|
||||
file.generate()
|
||||
except Exception as err:
|
||||
# TODO: How should we handle failures? Don't want to error, but should call it out more than this.
|
||||
self.stdout.write(' FAILED: %s\n' % err)
|
||||
for image_file in cachefile_registry.get(generator_id):
|
||||
if image_file.name:
|
||||
self.stdout.write(' %s\n' % image_file.name)
|
||||
try:
|
||||
image_file.generate()
|
||||
except MissingSource as err:
|
||||
self.stdout.write('\t No source associated with\n')
|
||||
except Exception as err:
|
||||
self.stdout.write('\tFailed %s\n' % (err))
|
||||
|
||||
def compile_patterns(self, generator_ids):
|
||||
return [self.compile_pattern(id) for id in generator_ids]
|
||||
|
|
|
|||
Loading…
Reference in a new issue