From 76d44b2cc907ca0e99b14f1ca0aa5f83ff261b3f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 17 Jul 2016 11:01:06 +0200 Subject: Add a short label to record relations --- ishtar_common/models.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ishtar_common') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index d8948d3e3..1e878d2a1 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -728,6 +728,8 @@ class BaseHistorizedItem(Imported): class GeneralRelationType(GeneralType): order = models.IntegerField(_(u"Order"), default=1) symmetrical = models.BooleanField(_(u"Symmetrical")) + short_label = models.CharField(_(u"Short label"), max_length=100, + blank=True, null=True) # # an inverse must be set # inverse_relation = models.ForeignKey( # 'RelationType', verbose_name=_(u"Inverse relation"), blank=True, @@ -742,6 +744,9 @@ class GeneralRelationType(GeneralType): raise ValidationError( _(u"Cannot have symmetrical and an inverse_relation")) + def get_short_label(self): + return self.short_label or self.label or u"" + def save(self, *args, **kwargs): obj = super(GeneralRelationType, self).save(*args, **kwargs) # after saving check that the inverse_relation of the inverse_relation -- cgit v1.2.3