From: Matthijs Kooijman Date: Tue, 13 Jan 2009 17:07:05 +0000 (+0100) Subject: Add a Characters.contacts propety. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=3b57264c77f8fc157a0129d406f4116c868c05b0;p=matthijs%2Fprojects%2Fxerxes.git Add a Characters.contacts propety. This property lists all the other characters that are contacts of a Character. The property is symmetrical, so if A is a contact of B, the reverse is also automatically the case. SQL: CREATE TABLE `influences_character_contacts` ( SQL: `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, SQL: `from_character_id` integer NOT NULL, SQL: `to_character_id` integer NOT NULL, SQL: UNIQUE (`from_character_id`, `to_character_id`) SQL: ); SQL: ALTER TABLE `influences_character_contacts` ADD SQL: CONSTRAINT from_character_id_refs_id_653bf18d29c7a4fa SQL: FOREIGN KEY (`from_character_id`) SQL: REFERENCES `influences_character` (`id`); SQL: ALTER TABLE `influences_character_contacts` ADD SQL: CONSTRAINT to_character_id_refs_id_653bf18d29c7a4fa SQL: FOREIGN KEY (`to_character_id`) SQL: REFERENCES `influences_character` (`id`); --- diff --git a/influences/models.py b/influences/models.py index 9fd77ef..9ba3f3c 100644 --- a/influences/models.py +++ b/influences/models.py @@ -22,6 +22,7 @@ class Character(models.Model): name = models.CharField(max_length=255, verbose_name = _("Name")) status = models.CharField(max_length=2, choices=STATUS_CHOICES, default='N', verbose_name = _("Status")) player = models.ForeignKey(User, verbose_name = _("Player")) + contacts = models.ManyToManyField('self') type = models.CharField(max_length=2, choices=TYPE_CHOICES, verbose_name=_("Type")) def __unicode__(self):