diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-04 17:11:52 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-04 17:11:52 +0200 |
commit | d0ce06a5899ee38a6c97a00c3f3512080a6169f8 (patch) | |
tree | 61235d58ad63a44cd66ddc0c2664bc3dd0ee3fa7 /archaeological_context_records/models.py | |
parent | 985dc2b18a551ead39a12fa0ed2601b2bda1d6e4 (diff) | |
download | Ishtar-d0ce06a5899ee38a6c97a00c3f3512080a6169f8.tar.bz2 Ishtar-d0ce06a5899ee38a6c97a00c3f3512080a6169f8.zip |
Admin context records: add context record lookup, improve admin forms
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) |