Le Fetch ouvre ensuite la page pour entrer un nouveau média (code sans doute temporaire)
This commit is contained in:
parent
39c3a59838
commit
0c9b3c4d5f
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% load i18n %}
|
||||
{% include "django/forms/widgets/input.html" %}
|
||||
<input type="submit" value="{% trans "Fetch data" %}" name="_continue">
|
||||
<input type="submit" value="{% trans "Fetch data" %}" name="_isbn">
|
||||
<input type="hidden" name="_addanother" value="42">
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue