diff options
-rw-r--r-- | archaeological_context_records/models.py | 2 | ||||
-rw-r--r-- | archaeological_finds/models_finds.py | 8 | ||||
-rw-r--r-- | archaeological_operations/models.py | 8 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 5 |
4 files changed, 13 insertions, 10 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 1c0acadbc..a112829f1 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -332,7 +332,7 @@ class ActivityType(GeneralType): class Meta: verbose_name = _("Activity Type") verbose_name_plural = _("Activity Types") - ordering = ("order",) + ordering = ("order", "label") def __str__(self): return self.label diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 398d20cf7..375cfc366 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -108,7 +108,7 @@ class MaterialTypeQualityType(GeneralType): class Meta: verbose_name = _("Material type quality type") verbose_name_plural = _("Material type quality types") - ordering = ("order",) + ordering = ("order", "label") ADMIN_SECTION = _("Finds") @@ -262,7 +262,7 @@ class BatchType(GeneralType): class Meta: verbose_name = _("Batch type") verbose_name_plural = _("Batch types") - ordering = ("order",) + ordering = ("order", "label") ADMIN_SECTION = _("Finds") @@ -338,7 +338,7 @@ class ObjectTypeQualityType(GeneralType): class Meta: verbose_name = _("Object type quality type") verbose_name_plural = _("Object type quality types") - ordering = ("order",) + ordering = ("order", "label") ADMIN_SECTION = _("Finds") @@ -409,7 +409,7 @@ class CheckedType(GeneralType): class Meta: verbose_name = _("Checked type") verbose_name_plural = _("Checked types") - ordering = ("order",) + ordering = ("order", "label") ADMIN_SECTION = _("Finds") diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 83e60866d..9d1a54d7d 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -111,7 +111,7 @@ class Period(GeneralType): class Meta: verbose_name = _("Type Period") verbose_name_plural = _("Types Period") - ordering = ("order",) + ordering = ("order", "label") def __str__(self): return self.label @@ -127,7 +127,7 @@ class ReportState(GeneralType): class Meta: verbose_name = _("Type of report state") verbose_name_plural = _("Types of report state") - ordering = ("order",) + ordering = ("order", "label") post_save.connect(post_save_cache, sender=ReportState) @@ -145,7 +145,7 @@ class RecordQualityType(GeneralType): class Meta: verbose_name = _("Type of record quality") verbose_name_plural = _("Types of record quality") - ordering = ("order",) + ordering = ("order", "label") class CulturalAttributionType(HierarchicalType): @@ -154,7 +154,7 @@ class CulturalAttributionType(HierarchicalType): class Meta: verbose_name = _("Cultural attribution type") verbose_name_plural = _("Cultural attribution types") - ordering = ("order",) + ordering = ("order", "label") post_save.connect(post_save_cache, sender=RecordQualityType) diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index b2cf02ef9..98c0c6933 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -491,8 +491,11 @@ class GeneralType(Cached, models.Model): childs = cls.objects.filter(**dct) if exclude: childs = childs.exclude(txt_idx__in=exclude) - if hasattr(cls, "order"): + ordering = cls._meta.ordering + if not ordering and hasattr(cls, "order"): childs = childs.order_by("order") + else: + childs = childs.order_by(*ordering) res = {} if instances: for item in childs.all(): |