From: Matthijs Kooijman Date: Tue, 13 Jan 2009 17:50:52 +0000 (+0100) Subject: Add Character.involved property. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fprojects%2Fxerxes.git;a=commitdiff_plain;h=fe2d9095c7819fbe98ae1448a8aba1094090cdd8 Add Character.involved property. This is a non-persistent property that joins other_characters and other_contacts together. --- diff --git a/influences/models.py b/influences/models.py index aa64f26..c513c1a 100644 --- a/influences/models.py +++ b/influences/models.py @@ -5,6 +5,7 @@ from django.utils.text import normalize_newlines from django.utils.translation import ugettext_lazy as _ from threadedcomments.models import ThreadedComment from xerxes.tools.text import rewrap +from string import strip # Create your models here. class Character(models.Model): @@ -93,6 +94,14 @@ class Influence(models.Model): prefix=prefix) return comments + @property + def involved(self): + """ Returns the Characters and contacts (strings) involved """ + chars = list(self.other_characters.all()) + if (self.other_contacts): + chars.extend(map(strip,self.other_contacts.split(','))) + return chars + class Meta: verbose_name = _("Influence") verbose_name_plural = _("Influences")