From f273b371a4c0e46fcdc97c68f459f8da0b777ca7 Mon Sep 17 00:00:00 2001 From: Jeremy Dunck Date: Sun, 30 Mar 2008 21:45:39 +0000 Subject: [PATCH] [gis] Tweaked layermapping to note updates to unique'd models. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7389 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/gis/utils/layermapping.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py index 3b85b3fac3..40d2e97278 100644 --- a/django/contrib/gis/utils/layermapping.py +++ b/django/contrib/gis/utils/layermapping.py @@ -597,6 +597,7 @@ class LayerMapping(object): stream.write('Ignoring Feature ID %s because: %s\n' % (feat.fid, msg)) else: # Constructing the model using the keyword args + is_update = False if self.unique: # If we want unique models on a particular field, handle the # geometry appropriately. @@ -605,6 +606,7 @@ class LayerMapping(object): # the unique model. u_kwargs = self.unique_kwargs(kwargs) m = self.model.objects.get(**u_kwargs) + is_update = True # Getting the geometry (in OGR form), creating # one from the kwargs WKT, adding in additional @@ -624,7 +626,7 @@ class LayerMapping(object): # Attempting to save. m.save() num_saved += 1 - if verbose: stream.write('Saved: %s\n' % m) + if verbose: stream.write('%s: %s\n' % (is_update and 'Updated' or 'Saved', m)) except SystemExit: raise except Exception, msg: