Skip to content

Commit

Permalink
Handle multiple Subcard levels in Search Export. #10199 (#10214)
Browse files Browse the repository at this point in the history
* Itterate through subcards to terminus.

* Amended to use inline fn.
  • Loading branch information
khodgkinson-he authored Nov 14, 2023
1 parent 966f53e commit c4e358f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions arches/app/search/search_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ def __init__(self, search_request=None):
self.output = {}
self.set_precision = GeoUtils().set_precision

def insert_subcard_below_parent_card(self, main_card_list, sub_card_list):
for sub_card in sub_card_list:
parent_obj = sub_card.nodegroup.parentnodegroup_id
for main_card in main_card_list:
if main_card.nodegroup_id == parent_obj:
index_number = main_card_list.index(main_card) + 1
main_card_list.insert(index_number, sub_card)
def insert_subcard_below_parent_card(self, main_card_list, sub_card_list, subcards_added):
for main_card in main_card_list:
sub_cards_to_add = []
for sub_card in sub_card_list:
if main_card.nodegroup_id == sub_card.nodegroup.parentnodegroup_id:
if sub_card not in main_card_list:
sub_cards_to_add.append(sub_card)
subcards_added = True
index_number = main_card_list.index(main_card) + 1
main_card_list[index_number:index_number] = sub_cards_to_add
return subcards_added


def return_ordered_header(self, graphid, export_type):

Expand All @@ -93,11 +98,14 @@ def return_ordered_header(self, graphid, export_type):

subcard_list_with_sort.sort(key=lambda x: x.sortorder, reverse=True)

self.insert_subcard_below_parent_card(sorted_card_list, card_list_no_sort)
def order_cards(subcards_added=True):
if subcards_added == True:
subcards_added = False
unsorted_subcards_added = self.insert_subcard_below_parent_card(sorted_card_list, card_list_no_sort, subcards_added)
sorted_subcards_added = self.insert_subcard_below_parent_card(sorted_card_list, subcard_list_with_sort, unsorted_subcards_added)
order_cards(sorted_subcards_added)

# Cards in subcard_list_with_sort are added after cards with no sort

self.insert_subcard_below_parent_card(sorted_card_list, subcard_list_with_sort)
order_cards()

# Create a list of nodes within each card and order them according to sort
# order then add them to the main list of
Expand Down

0 comments on commit c4e358f

Please sign in to comment.