Verified Commit 079ade9b authored by ynerant's avatar ynerant
Browse files

Fix ISBN scraper

parent 4928b555
Pipeline #9515 passed with stages
in 2 minutes and 45 seconds
......@@ -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 \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment