diff --git a/media/forms.py b/media/forms.py index b3c3775..f904bf4 100644 --- a/media/forms.py +++ b/media/forms.py @@ -26,6 +26,8 @@ class MediaAdminForm(ModelForm): Download data from bedeteque :return True if success """ + print(self.request.POST) + print('isbn' in self.request.POST) scraper = BedetequeScraper() r = scraper.search_by_isbn(isbn) if not r: @@ -33,7 +35,6 @@ class MediaAdminForm(ModelForm): # If results, then take the most accurate data = scraper.scrap_bd_info(r[0]) self.cleaned_data.update(data) - print(self.cleaned_data) return True def download_data_openlibrary(self, isbn): @@ -93,7 +94,7 @@ class MediaAdminForm(ModelForm): """ super().clean() - if "_continue" in self.request.POST: + if "_isbn" in self.request.POST: isbn = self.cleaned_data.get('isbn') if isbn: # ISBN is present, try with bedeteque @@ -175,7 +176,7 @@ class MediaAdminForm(ModelForm): from django.core.exceptions import ValidationError try: # We don't want to check a field when we enter an ISBN. - if "_continue" not in self.request.POST \ + if "isbn" not in self.request.POST \ or not self.cleaned_data.get('isbn'): value = field.clean(value) self.cleaned_data[name] = value diff --git a/media/templates/media/isbn_button.html b/media/templates/media/isbn_button.html index 36bd9b2..1d1903d 100644 --- a/media/templates/media/isbn_button.html +++ b/media/templates/media/isbn_button.html @@ -1,3 +1,4 @@ {% load i18n %} {% include "django/forms/widgets/input.html" %} - \ No newline at end of file + + \ No newline at end of file diff --git a/tool_barcode_getblue.py b/tool_barcode_getblue.py index fd5b8cf..533414a 100644 --- a/tool_barcode_getblue.py +++ b/tool_barcode_getblue.py @@ -22,6 +22,9 @@ class Server(BaseHTTPRequestHandler): def do_GET(self): self._set_headers() isbn = self.path[7:-24] + if not isbn.isnumeric(): + print("Mauvais ISBN.") + return print("Hey j'ai un ISBN :", isbn) os.system("xdotool type " + isbn) os.system("xdotool key KP_Enter")