diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index ccc3268f4..243ce32f8 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -76,6 +76,20 @@ class Dating(models.Model): return unicode(self.period) return u"%s (%s-%s)" % (self.period, start_date, end_date) + def context_records_lbl(self): + return u" - ".join( + [cr.cached_label for cr in self.context_records.all()] + ) + context_records_lbl.short_description = _(u"Context record") + context_records_lbl.admin_order_field = "context_records__cached_label" + + def finds_lbl(self): + return u" - ".join( + [f.cached_label for f in self.find.all()] + ) + finds_lbl.short_description = _(u"Find") + finds_lbl.admin_order_field = "find__cached_label" + @classmethod def fix_dating_association(cls, obj): """ @@ -250,7 +264,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, ImageModel, OwnPerms, _(u"Location"), blank=True, null=True, help_text=_(u"A short description of the location of the context " u"record")) - datings = models.ManyToManyField(Dating) + datings = models.ManyToManyField(Dating, related_name='context_records') documentations = models.ManyToManyField(DocumentationType, blank=True) datings_comment = models.TextField(_(u"Comment on datings"), blank=True, null=True) |