summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-02-26 20:00:21 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-05-06 16:04:02 +0200
commit7e76b86d6f0176f9561876ae465e1483b15a246f (patch)
tree3982f2a204b906384ea665d7d71a1c8e1c38cab6 /ishtar_common
parenta49b3d93a8338bb5680fda8d40df22415f4975be (diff)
downloadIshtar-7e76b86d6f0176f9561876ae465e1483b15a246f.tar.bz2
Ishtar-7e76b86d6f0176f9561876ae465e1483b15a246f.zip
Automatically update raw_general_contractor and raw_town_planning_service on save - improve pdl import of raw_names and of dates
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/data_importer.py7
-rw-r--r--ishtar_common/models.py9
2 files changed, 16 insertions, 0 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index 6b021e6f3..09c511a25 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -449,6 +449,13 @@ class StrToBoolean(Formater, ChoiceChecker):
logger = logging.getLogger(__name__)
+def get_object_from_path(obj, path):
+ for k in path.split('__')[:-1]:
+ if not hasattr(obj, k):
+ return
+ obj = getattr(obj, k)
+ return obj
+
class Importer(object):
DESC = ""
LINE_FORMAT = []
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index d5e0e5fc5..a99470c2b 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1630,6 +1630,15 @@ class Person(Address, Merge, OwnPerms, ValueGetter) :
if getattr(self, attr)]
return slugify(u"-".join(values))
+ def save(self, *args, **kwargs):
+ super(Person, self).save(*args, **kwargs)
+ if hasattr(self, 'responsible_town_planning_service'):
+ for fle in self.responsible_town_planning_service.all():
+ fle.save() # force update of raw_town_planning_service
+ if hasattr(self, 'general_contractor'):
+ for fle in self.general_contractor.all():
+ fle.save() # force update of raw_general_contractor
+
class IshtarUser(User):
person = models.ForeignKey(Person, verbose_name=_(u"Person"), unique=True,
related_name='ishtaruser')