From 09b98c80401cc73820c8095121ff0886e956d1e7 Mon Sep 17 00:00:00 2001 From: Janani Neelamekam Date: Tue, 19 Dec 2023 15:51:08 -0800 Subject: [PATCH] Changes to support export on historic incidents --- src/dispatch/event/service.py | 4 +--- .../plugins/dispatch_google/docs/plugin.py | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dispatch/event/service.py b/src/dispatch/event/service.py index 12c990fa4f6c..9d1a3cbca870 100644 --- a/src/dispatch/event/service.py +++ b/src/dispatch/event/service.py @@ -202,8 +202,6 @@ def delete_incident_event( """Deletes an event.""" event = get_by_uuid(db_session=db_session, uuid=uuid) log.debug("Deleting incident event") - log.debug(event) - log.debug(event.id) delete(db_session=db_session, event_id=event.id) @@ -298,7 +296,7 @@ def export_timeline( } ] if plugin.instance.delete_table(document_id=doc_id, request=delete_table_request): - log.debug("Existing Table in the doc has been deleted") + log.debug("Existing table in the doc has been deleted") else: curr_table_start += 1 diff --git a/src/dispatch/plugins/dispatch_google/docs/plugin.py b/src/dispatch/plugins/dispatch_google/docs/plugin.py index 346f6ca6154e..797fadc26077 100644 --- a/src/dispatch/plugins/dispatch_google/docs/plugin.py +++ b/src/dispatch/plugins/dispatch_google/docs/plugin.py @@ -87,6 +87,8 @@ def get_table_details(self, document_id: str, header: str): header_section = False table_exists = False table_indices = [] + log.debug(document_content) + headingId = "" for i, element in enumerate(document_content): if "paragraph" in element and "elements" in element["paragraph"]: for item in element["paragraph"]["elements"]: @@ -94,20 +96,26 @@ def get_table_details(self, document_id: str, header: str): if item["textRun"]["content"].strip() == header: header_index = element["endIndex"] header_section = True + headingId = element["paragraph"].get("paragraphStyle")["headingId"] elif header_section: + # Gets the end index of any text below the header if ( header_section and item["textRun"]["content"].strip() - and "headingId" - not in element["paragraph"].get("paragraphStyle", {}) + and element["paragraph"].get("paragraphStyle")["headingId"] + != headingId ): header_index = item["endIndex"] # checking if we are past header in question - if any( - "headingId" in style - for style in element["paragraph"]["paragraphStyle"] - for style in element["paragraph"].get("paragraphStyle", {}) + if ( + any( + "headingId" in style + for style in element["paragraph"]["paragraphStyle"] + for style in element["paragraph"].get("paragraphStyle", {}) + ) + and element["paragraph"].get("paragraphStyle")["headingId"] + != headingId ): past_header = True header_section = False