diff --git a/directory/management/commands/import_refs_by_external_code.py b/directory/management/commands/import_refs_by_external_code.py index 59caec72cf..c6988d932e 100644 --- a/directory/management/commands/import_refs_by_external_code.py +++ b/directory/management/commands/import_refs_by_external_code.py @@ -27,7 +27,7 @@ def handle(self, *args, **kwargs): ws = wb[wb.sheetnames[0]] starts = False - code_idx, conditions_idx, start_ref_idx, end_ref_idx = None, None, None, None + code_idx, title_idx, conditions_idx, start_ref_idx, end_ref_idx = None, None, None, None, None fraction = None result_wb = Workbook() result_ws = result_wb[result_wb.sheetnames[0]] @@ -39,15 +39,18 @@ def handle(self, *args, **kwargs): if "Условия" in cells: code_idx = cells.index("Код") conditions_idx = cells.index("Условия") + title_idx = cells.index("Тест") start_ref_idx = cells.index("Нижняя Гр.") end_ref_idx = cells.index("Верхняя Гр.") starts = True else: code = cells[code_idx].strip() + title = cells[title_idx].strip() conditions = cells[conditions_idx].strip() start = cells[start_ref_idx].strip() end = cells[end_ref_idx].strip() if start == "None" or end == "None": + result_ws.append([code, title, '-']) continue tmp_cond_str = conditions.split("Пол: ") age = "" @@ -71,6 +74,7 @@ def handle(self, *args, **kwargs): age = f"дней {age_start}-{age_end}" except Exception: self.stdout.write("Не удалось преобразовать в дни") + result_ws.append([code, title, '-']) continue elif not age: age = "Все" @@ -89,6 +93,7 @@ def handle(self, *args, **kwargs): ref_m, ref_f = [], [] fraction = Fractions.objects.filter(external_code__iexact=code).first() if not fraction: + result_ws.append([code, title, '-']) continue if gender.lower() == "общий":