mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-26 18:00:23 +00:00
add_source -> add_sources; switch argument order
This commit is contained in:
parent
bdec396180
commit
adf143edc5
2 changed files with 10 additions and 9 deletions
|
|
@ -43,8 +43,8 @@ class ImageSpecField(SpecHostField):
|
|||
self.set_spec_id(cls, name)
|
||||
|
||||
# Add the model and field as a source for this spec id
|
||||
specs.registry.add_source(ImageFieldSpecSource(cls, self.image_field),
|
||||
self.spec_id)
|
||||
specs.registry.add_sources(self.spec_id,
|
||||
[ImageFieldSpecSource(cls, self.image_field)])
|
||||
|
||||
|
||||
class ProcessedImageField(models.ImageField, SpecHostField):
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ class SpecRegistry(object):
|
|||
raise AlreadyRegistered('The spec with id %s is already registered' % id)
|
||||
self._specs[id] = spec
|
||||
|
||||
for source in getattr(config, 'sources', None) or []:
|
||||
self.add_source(source, id)
|
||||
sources = getattr(config, 'sources', None) or []
|
||||
self.add_sources(id, sources)
|
||||
|
||||
def unregister(self, id, spec):
|
||||
try:
|
||||
|
|
@ -72,14 +72,15 @@ class SpecRegistry(object):
|
|||
else:
|
||||
return spec
|
||||
|
||||
def add_source(self, source, spec_id):
|
||||
def add_sources(self, spec_id, sources):
|
||||
"""
|
||||
Associates a source with a spec id
|
||||
Associates sources with a spec id
|
||||
|
||||
"""
|
||||
if source not in self._sources:
|
||||
self._sources[source] = set()
|
||||
self._sources[source].add(spec_id)
|
||||
for source in sources:
|
||||
if source not in self._sources:
|
||||
self._sources[source] = set()
|
||||
self._sources[source].add(spec_id)
|
||||
|
||||
def before_access_receiver(self, sender, spec, file, **kwargs):
|
||||
spec.image_cache_strategy.invoke_callback('before_access', file)
|
||||
|
|
|
|||
Loading…
Reference in a new issue