From 8d225a8b5b0cd03622ffe610971bdb13559493a5 Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 20 Jun 2024 14:29:18 +0200 Subject: [PATCH] Show author of object --- apis_ontology/tables.py | 51 ++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/apis_ontology/tables.py b/apis_ontology/tables.py index 684cc43..6814b57 100644 --- a/apis_ontology/tables.py +++ b/apis_ontology/tables.py @@ -215,21 +215,27 @@ def __init__(self, *args, **kwargs): self.transform = etree.XSLT(xslt) def render_name(self, record): - if self.context["object"].pk == record.subj.pk: - return record.name - elif self.context["object"].pk == record.obj.pk: - return record.reverse_name - else: - return "" + rel_name = record.name + try: + if self.context["object"].pk == record.obj.pk: + rel_name = record.reverse_name + except Exception as e: + logger.error("Bad relation %s\Error: %s", record, repr(e)) + + return rel_name def render_obj(self, record): # return str(record) + str(self.context["object"].pk) - if self.context["object"].pk == record.obj.pk: - # return str(RootObject.objects_inheritance.get_subclass(pk=record.subj.pk)) - actual_obj = RootObject.objects_inheritance.get_subclass(pk=record.subj.pk) + actual_obj = RootObject.objects_inheritance.get_subclass(pk=record.obj.pk) - else: - actual_obj = RootObject.objects_inheritance.get_subclass(pk=record.obj.pk) + try: + if self.context["object"].pk == record.obj.pk: + # return str(RootObject.objects_inheritance.get_subclass(pk=record.subj.pk)) + actual_obj = RootObject.objects_inheritance.get_subclass( + pk=record.subj.pk + ) + except Exception as e: + logger.error("Bad relation %s\Error: %s", record, repr(e)) return mark_safe( "