diff --git a/src/meshdb/utils/spreadsheet_import/main.py b/src/meshdb/utils/spreadsheet_import/main.py index f1817e17..f0644e90 100644 --- a/src/meshdb/utils/spreadsheet_import/main.py +++ b/src/meshdb/utils/spreadsheet_import/main.py @@ -238,8 +238,11 @@ def main(): logging.info(f"Doing one last scan pass to to check device / node activity consistency") for node in models.Node.objects.filter(status=models.Node.NodeStatus.INACTIVE).prefetch_related("devices"): - if any(device.status == models.Device.DeviceStatus.ACTIVE for device in node.devices.all()): - logging.info(f"Found active devices on inactive node {node}, marking active") + if any( + device.status == models.Device.DeviceStatus.ACTIVE and "Placeholder Device" not in device.name + for device in node.devices.all() + ): + logging.info(f"Found active non-placeholder devices on inactive node {node}, marking active") node.status = models.Node.NodeStatus.ACTIVE node.save() diff --git a/src/meshdb/utils/spreadsheet_import/parse_link.py b/src/meshdb/utils/spreadsheet_import/parse_link.py index 2b0183ed..dc36fc82 100644 --- a/src/meshdb/utils/spreadsheet_import/parse_link.py +++ b/src/meshdb/utils/spreadsheet_import/parse_link.py @@ -128,7 +128,7 @@ def find_access_point_from_install_number(install_number: int) -> Optional[Acces def create_spreadsheet_link_notes(spreadsheet_link: SpreadsheetLink): notes = ( f"Imported from spreadsheet link row " - + f"{spreadsheet_link.from_node_id}->{spreadsheet_link.to_node_id} ({spreadsheet_link.status})\n" + + f"{spreadsheet_link.from_node_id}->{spreadsheet_link.to_node_id} ({spreadsheet_link.status.value})\n" + "\n".join( s.strip() for s in [spreadsheet_link.where_to_where, spreadsheet_link.notes, spreadsheet_link.comments] diff --git a/src/meshdb/utils/spreadsheet_import/parse_node.py b/src/meshdb/utils/spreadsheet_import/parse_node.py index 1c5cccb1..1352d955 100644 --- a/src/meshdb/utils/spreadsheet_import/parse_node.py +++ b/src/meshdb/utils/spreadsheet_import/parse_node.py @@ -48,9 +48,6 @@ def get_spreadsheet_node_notes(row: SpreadsheetRow) -> str: if row.notes2: notes = f"Spreadsheet Notes2 (#{row.id}):\n{row.notes}" - if notes: - notes += f"-------\n\n" - return notes @@ -88,12 +85,10 @@ def get_or_create_node( node.type = new_type if row.notes or row.notes2: - node.notes += ( - f"Spreadsheet Notes (#{row.id}):\n" - f"{row.notes if row.notes else None}\n\n" - f"Spreadsheet Notes2 (#{row.id}):\n" - f"{row.notes2 if row.notes2 else None}\n\n" - ) + if row.notes: + node.notes += f"Spreadsheet Notes (#{row.id}):\n{row.notes}\n\n" + if row.notes2: + node.notes += f"Spreadsheet Notes2 (#{row.id}):\n{row.notes2}\n\n" return node