From c69d1a9c1368ecaa6d4ee2cea662a9cfa0c61a9f Mon Sep 17 00:00:00 2001 From: John Connor Date: Mon, 4 Nov 2024 20:32:04 -0400 Subject: [PATCH 1/2] filebrowser bug fixed and now searching enslaver identities as well as aliases on voyages filters --- src/api/common/reqs.py | 7 ++++--- src/api/voyages3/settings.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/common/reqs.py b/src/api/common/reqs.py index 0b128b3..2fdfcdf 100755 --- a/src/api/common/reqs.py +++ b/src/api/common/reqs.py @@ -205,11 +205,12 @@ def post_req(orig_queryset,s,r,options_dict,auto_prefetch=True,paginate=False): # so we filter on each chunk of the name, serially, stripped of punctuation qobjstrs=[] for namesegment in namesegments: - qobjstr=f'Q(voyage_enslavement_relations__relation_enslavers__enslaver_alias__alias__icontains="{namesegment}")' + qobjstr=f'Q(voyage_enslavement_relations__relation_enslavers__enslaver_alias__alias__icontains="{namesegment}")|\ + Q(voyage_enslavement_relations__relation_enslavers__enslaver_alias__identity__principal_alias__icontains="{namesegment}")' qobjstrs.append(qobjstr) qobjstr=' , '.join(qobjstrs) execobjstr=f'filtered_queryset.filter({qobjstr})' -# print("EXECOBJSTR",execobjstr) + print("EXECOBJSTR",execobjstr) enslavernamehits=eval(execobjstr) # print("enslavernamehits",enslavernamehits) # print("enslavernamehitscount",enslavernamehits.count()) @@ -222,7 +223,7 @@ def post_req(orig_queryset,s,r,options_dict,auto_prefetch=True,paginate=False): eirs_unfiltered=er.relation_enslavers.all() qobjstrs=[] for namesegment in namesegments: - qobjstr=f'Q(enslaver_alias__alias__icontains="{namesegment}")' + qobjstr=f'Q(enslaver_alias__alias__icontains="{namesegment}")|Q(enslaver_alias__identity__principal_alias__icontains="{namesegment}")' # print("--->",qobjstr) qobjstrs.append(qobjstr) qobjstr=' , '.join(qobjstrs) diff --git a/src/api/voyages3/settings.py b/src/api/voyages3/settings.py index b3e64bc..3c924e3 100644 --- a/src/api/voyages3/settings.py +++ b/src/api/voyages3/settings.py @@ -194,8 +194,8 @@ site = FileBrowserSite(name='filebrowser') site.storage.location = "static" -site.directory="uploads/" -site.storage.base_url = "/abcdefg" +site.directory="static/uploads/" +site.storage.base_url = "/static/uploads" TINYMCE_JS_URL="tinymce/tinymce.min.js" TINYMCE_DEFAULT_CONFIG = { From 1066fabe839f664afd7c0b27d9bf037c05f473a4 Mon Sep 17 00:00:00 2001 From: John Connor Date: Tue, 5 Nov 2024 22:14:13 -0400 Subject: [PATCH 2/2] patched texas import and network utils --- .../management/commands/texas_import_2.py | 26 ++++++++++++------- src/people-networks/utils.py | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/api/document/management/commands/texas_import_2.py b/src/api/document/management/commands/texas_import_2.py index db65a61..08563af 100644 --- a/src/api/document/management/commands/texas_import_2.py +++ b/src/api/document/management/commands/texas_import_2.py @@ -70,12 +70,14 @@ def handle(self, *args, **options): except: pass - EnslaverAlias.objects.all().filter( + texas_enslaver_aliases=EnslaverAlias.objects.all().filter( manual_id__icontains='TEXAS_ENSLAVER' - ).delete() - - - + ) + + for tea in texas_enslaver_aliases: + tea.identity.delete() + tea.delete() + # 1. Run through the two spreadsheets # A. & create new enslaver identities off each unique name, keeping an alias id for each # 1. texas_voyage_enslavers: @@ -122,18 +124,22 @@ def handle(self, *args, **options): identity,identity_isnew=EnslaverIdentity.objects.get_or_create( principal_alias=enslaver_name, -# manual_id=texas_id ) -# if vid=='135509': -# print("AAA",enslaver_name) - - alias,alias_isnew=EnslaverAlias.objects.get_or_create( + aliases=EnslaverAlias.objects.filter( alias=enslaver_name, identity=identity ) + if len(aliases)==0: + alias=EnslaverAlias.objects.create( + alias=enslaver_name, + identity=identity + ) + else: + alias=aliases[0] + alias.manual_id=texas_id alias.save() diff --git a/src/people-networks/utils.py b/src/people-networks/utils.py index e3c97d2..3e5a307 100644 --- a/src/people-networks/utils.py +++ b/src/people-networks/utils.py @@ -242,6 +242,9 @@ def load_graph(): else: if len(voyage_uuids)>1: print("more voyages than we counted on",rc) + elif len(voyage_uuids)==0: + pass +# print(relations_dict) else: voyage_uuid=voyage_uuids[0] # if we have a single voyage, then we know that we're dealing with