From 8e88bf8226b4104908b7278d46611486e9842ea7 Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 12 Dec 2024 13:02:11 +0100 Subject: [PATCH 1/5] order subject by name --- apis_ontology/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 35c6a39..ce6bacd 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -28,6 +28,7 @@ def __str__(self): class Meta: verbose_name = _("Subject") verbose_name_plural = _("Subjects") + ordering = ["name"] class TibScholEntityMixin(models.Model): From 586e194b207cb3601aee97c6202503b7557de8bb Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 12 Dec 2024 13:04:43 +0100 Subject: [PATCH 2/5] order person by name --- apis_ontology/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index ce6bacd..4dc0006 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -114,6 +114,7 @@ class Person( class Meta: verbose_name = _("person") verbose_name_plural = _("Persons") + ordering = ["name", "pk"] def __str__(self): return f"{self.name} ({self.pk})" From 5563429febc8ef78f0ade812c0ebbbf62ac0f31f Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 12 Dec 2024 13:05:47 +0100 Subject: [PATCH 3/5] order works by name --- apis_ontology/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 4dc0006..08aace6 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -213,6 +213,7 @@ class Work( class Meta: verbose_name = _("work") verbose_name_plural = _("Works") + ordering = ["name", "pk"] def __str__(self): return f"{self.name} ({self.pk})" From 694d2ae7bededbb977e11bb7724c8cb81423ac7d Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 12 Dec 2024 13:12:59 +0100 Subject: [PATCH 4/5] order instances by name --- apis_ontology/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 08aace6..0c4953f 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -331,6 +331,7 @@ class Instance( class Meta: verbose_name = _("instance") verbose_name_plural = _("Instances") + ordering = ["name", "pk"] def __str__(self): return f"{self.name} ({self.pk})" From 811e485cbbe72d2afb377a3db4b26972aefaf496 Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Thu, 12 Dec 2024 13:19:28 +0100 Subject: [PATCH 5/5] order relations by subj/obj id (default) Not ideal, they should be ordered by the names instead. --- apis_ontology/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index 0c4953f..8a31e08 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -394,14 +394,15 @@ class Meta: abstract = True -def enforce_plural_name(sender, **kwargs): +def enforce_meta_attributes(sender, **kwargs): if issubclass(sender, TibScholRelationMixin): meta = sender._meta # set verbose_name_plural to verbose_name meta.verbose_name_plural = meta.verbose_name or sender.__name__.lower() + meta.ordering = ["subj_object_id", "obj_object_id"] -class_prepared.connect(enforce_plural_name) +class_prepared.connect(enforce_meta_attributes) class PersonActiveAtPlace(TibScholRelationMixin):