diff options
Diffstat (limited to 'ishtar/furnitures/models.py')
| -rw-r--r-- | ishtar/furnitures/models.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index db8773ad4..02c3661a5 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -28,6 +28,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext from django.db.utils import DatabaseError from django.utils.safestring import SafeUnicode from django.db.models import Q, Max +from django.db.models.signals import m2m_changed from django.contrib.auth.models import User from django.contrib.gis.db import models @@ -298,7 +299,7 @@ class Address(BaseHistorizedItem): address_complement = models.TextField(_(u"Address complement"), null=True, blank=True) postal_code = models.CharField(_(u"Postal code"), max_length=10, null=True, - blank=True) + blank=True) town = models.CharField(_(u"Town"), max_length=30, null=True, blank=True) country = models.CharField(_(u"Country"), max_length=30, null=True, blank=True) @@ -868,7 +869,6 @@ class BaseItem(BaseHistorizedItem, OwnPerms): self.index, self.context_record.label, self.label)]) - class Item(BaseHistorizedItem, OwnPerms): TABLE_COLS = ['base_items.context_record.parcel.town', 'base_items.context_record.parcel.operation.year', @@ -926,6 +926,25 @@ class Item(BaseHistorizedItem, OwnPerms): base_item.save() super(Item, self).save(*args, **kwargs) +""" +def initialize_item(sender, **kwargs): + # initialize base items with the item + if kwargs['action'] != 'post_add': + return + item = kwargs['instance'] + # item already initialized + if item.label: + return + base_items = item.base_items.all() + if len(base_items) != 1: + return + base_item = base_items[0] + item.label = base_item.label + item.description = base_item.description + item.save() +m2m_changed.connect(initialize_item, + sender=Item.base_items.through) +""" class ParcelOwner(LightHistorizedItem): owner = models.ForeignKey(Person, verbose_name=_(u"Owner")) |
