Clean other editor when a real editor is found

This commit is contained in:
Gabriel Augendre 2020-06-30 13:18:54 +02:00
parent df8ef43b58
commit d235f61e5a
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4

View file

@ -290,8 +290,12 @@ class Book(BaseModel):
potential_editor = (
Editor.objects.filter(name__iexact=editor).first()
or Editor.objects.filter(name__icontains=editor).first()
or Editor.objects.get(name__istartswith="autre")
)
if potential_editor:
self.other_editor = ""
else:
potential_editor = Editor.objects.get(name__istartswith="autre")
self.other_editor = editor
self.editor = potential_editor
self.save()