1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-25 05:42:24 +00:00

Fix ISBN scraper

This commit is contained in:
Yohann D'ANELLO 2021-10-26 15:35:47 +02:00
parent 4928b555b7
commit 079ade9bbb
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -9,6 +9,7 @@ import unicodedata
from urllib.error import HTTPError
import urllib.request
from django.core.exceptions import ValidationError
from django.db.models import QuerySet
from django.forms import ModelForm
from django.utils.translation import gettext_lazy as _
@ -320,6 +321,13 @@ class MediaAdminForm(ModelForm):
return self.cleaned_data
def _clean_fields(self):
# First clean ISBN field
isbn_field = self.fields['isbn']
isbn = isbn_field.widget.value_from_datadict(
self.data, self.files, self.add_prefix('isbn'))
isbn = isbn_field.clean(isbn)
self.cleaned_data['isbn'] = isbn
for name, field in self.fields.items():
# value_from_datadict() gets the data from the data dictionaries.
# Each widget type knows how to retrieve its own data, because some
@ -329,7 +337,6 @@ class MediaAdminForm(ModelForm):
else:
value = field.widget.value_from_datadict(
self.data, self.files, self.add_prefix(name))
from django.core.exceptions import ValidationError
try:
# We don't want to check a field when we enter an ISBN.
if "isbn" not in self.data \