From 343ab028740465ed287c05d85d6f6aee1f96001f Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 10 Feb 2020 19:33:34 +0100 Subject: [PATCH] Fixed publish date when there is only the year --- media/forms.py | 9 ++++++--- tool_barcode_getblue.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/media/forms.py b/media/forms.py index 393024f..9aaf0bf 100644 --- a/media/forms.py +++ b/media/forms.py @@ -72,9 +72,12 @@ class MediaAdminForm(ModelForm): "June", "July", "August", "September", "October", "November", "December"] split = data['publish_date'].replace(',', '').split(' ') - self.cleaned_data['publish_date'] = "{}-{:02d}-{:02d}" \ - .format(split[2], months.index(split[0]) + 1, - int(split[1]), ) + if len(split) == 1: + self.cleaned_data['publish_date'] = split[0] + "-01-01" + else: + self.cleaned_data['publish_date'] = "{}-{:02d}-{:02d}" \ + .format(split[2], months.index(split[0]) + 1, + int(split[1]), ) if 'authors' in data: if 'author' not in self.cleaned_data: diff --git a/tool_barcode_getblue.py b/tool_barcode_getblue.py index 2a24235..fd5b8cf 100644 --- a/tool_barcode_getblue.py +++ b/tool_barcode_getblue.py @@ -2,6 +2,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer import os import socket +from time import sleep """ GetBlue Android parameters @@ -24,6 +25,8 @@ class Server(BaseHTTPRequestHandler): print("Hey j'ai un ISBN :", isbn) os.system("xdotool type " + isbn) os.system("xdotool key KP_Enter") + sleep(1) + os.system("xdotool click 1") def do_HEAD(self): self._set_headers()