Fix editor retrieval when multiple editors are returned
This commit is contained in:
parent
0bdbe79828
commit
df8ef43b58
1 changed files with 8 additions and 5 deletions
|
@ -285,12 +285,15 @@ class Book(BaseModel):
|
|||
self.authors = decitre_data.get('authors')
|
||||
self.price = decitre_data.get('price')
|
||||
self.publication_year = decitre_data.get('year')
|
||||
editor = decitre_data.get('editor')
|
||||
try:
|
||||
self.editor = Editor.objects.get(name__icontains=editor)
|
||||
except Editor.DoesNotExist:
|
||||
self.editor = Editor.objects.get(name__istartswith='autre')
|
||||
|
||||
editor = decitre_data.get('editor')
|
||||
potential_editor = (
|
||||
Editor.objects.filter(name__iexact=editor).first()
|
||||
or Editor.objects.filter(name__icontains=editor).first()
|
||||
or Editor.objects.get(name__istartswith="autre")
|
||||
)
|
||||
|
||||
self.editor = potential_editor
|
||||
self.save()
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in a new issue