From 3af2645706049813483289b6a4344432d863288f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 5 Jul 2022 18:36:27 +0200 Subject: [PATCH] fix format of file --- ereuse_devicehub/inventory/forms.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index aed0d7da..306744c9 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -1458,7 +1458,11 @@ class UploadPlaceholderForm(FlaskForm): for k, v in x.items(): data[head[i]][k] = v[i] else: - data = pd.read_excel(_file).to_dict() + try: + data = pd.read_excel(_file).to_dict() + except ValueError: + self.placeholder_file.errors = ["File don't have a correct format"] + return False return data @@ -1472,6 +1476,8 @@ class UploadPlaceholderForm(FlaskForm): return False data = self.get_data_file() + if not data: + return False header = [ 'Phid',