diff --git a/apis_ontology/management/commands/fetch_zotero_entries.py b/apis_ontology/management/commands/fetch_zotero_entries.py index 132e6bb..fc1e2b4 100644 --- a/apis_ontology/management/commands/fetch_zotero_entries.py +++ b/apis_ontology/management/commands/fetch_zotero_entries.py @@ -29,7 +29,7 @@ def handle(self, *args, **kwargs): res = requests.get(QUERY_URL, headers=HEADERS, params=PARAMS) res.raise_for_status() num_records = res.headers["Total-Results"] - + print(f"Found {len(num_records)} records") all_items = [] for start in tqdm(range(0, int(num_records), 25)): PARAMS["start"] = start @@ -37,10 +37,12 @@ def handle(self, *args, **kwargs): res.raise_for_status() items = res.json() + print(f"Fetched {len(items)}.") all_items.extend(items) df = pd.json_normalize(all_items) - + print(f"Fetched {df.shape[0]} items in total") + print(f"... of which there are {len(df['data.key'].unique())} are unique keys.") for i, row in tqdm(df.iterrows(), total=df.shape[0]): if "apis" in [tag["tag"].lower() for tag in row["data.tags"]]: zotero_entry, _ = ZoteroEntry.objects.get_or_create( diff --git a/apis_ontology/tables.py b/apis_ontology/tables.py index af5cb2a..9e69dde 100644 --- a/apis_ontology/tables.py +++ b/apis_ontology/tables.py @@ -4,7 +4,11 @@ from django_tables2.utils import A from .models import Instance, Person, Place, TibScholRelationMixin, Work -from .templatetags.filter_utils import render_coordinate, render_links +from .templatetags.filter_utils import ( + render_coordinate, + render_links, + render_list_field, +) from .templatetags.parse_comment import parse_comment import django_tables2 as tables @@ -118,7 +122,7 @@ def render_support_notes(self, value): return mark_safe(parse_comment(value)) def render_zotero_refs(self, value): - return mark_safe(parse_comment(value)) + return mark_safe(parse_comment(render_list_field(value))) def render_obj(self, record): # return str(record) + str(self.context["object"].pk) diff --git a/apis_ontology/templatetags/parse_comment.py b/apis_ontology/templatetags/parse_comment.py index a1483b3..6406d50 100644 --- a/apis_ontology/templatetags/parse_comment.py +++ b/apis_ontology/templatetags/parse_comment.py @@ -41,12 +41,14 @@ def custom_replace(match): try: root_obj = RootObject.objects_inheritance.get_subclass(pk=entity_id) ct = ContentType.objects.get_for_model(root_obj) - return f'{entity_id}' + return f'({entity_id})' except Exception as e: logger.error("Error finding entity #%s", entity_id) logger.error(repr(e)) - return f'{entity_id}' + return ( + f'({entity_id})' + ) else: # If no specific group is matched, return the original match replacement = match.group(0)