diff options
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/models_finds.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 25563edd0..b0c5a0332 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -1684,8 +1684,17 @@ class Find(BulkUpdatedItem, ValueGetter, DocumentItem, BaseHistorizedItem, @property def materials(self): - return u" ; ".join([str(material) - for material in self.material_types.all()]) + return " ; ".join([str(material) + for material in self.material_types.all()]) + + def get_first_material_type(self): + model = self.__class__.material_types.through + q = model.objects.filter(find=self) + if not q.count(): + return + if q.filter(materialtype__parent__isnull=True).count(): + q = q.filter(materialtype__parent__isnull=True) + return q.order_by("materialtype__label")[0].materialtype @property def show_url(self): |