Skip to content

Commit

Permalink
handle update if thing is queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 4, 2020
1 parent 1eff549 commit e27fde9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions shop/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ def prepare_body(self, instance):
body = template.render({'product': instance})
return body

def update(self, product, refresh=None, action='index', parallel=False, **kwargs):
if product.active:
if self._language:
with translation.override(self._language):
super().update(product, refresh=None, action='index', parallel=False, **kwargs)
else:
super().update(product, refresh=None, action='index', parallel=False, **kwargs)
else:
def update(self, thing, refresh=None, action='index', parallel=False, **kwargs):
if isinstance(thing, ProductModel._materialized_model) and thing.active is False:
try:
doc = self.get(id=product.id)
doc = self.get(id=thing.id)
except NotFoundError:
pass
else:
doc.delete()
else:
if self._language:
with translation.override(self._language):
super().update(thing, refresh=None, action='index', parallel=False, **kwargs)
else:
super().update(thing, refresh=None, action='index', parallel=False, **kwargs)


class ProductDocument:
Expand Down

0 comments on commit e27fde9

Please sign in to comment.