summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2015-11-25 14:33:22 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2015-11-25 14:33:22 (GMT)
commita0b156ffabba27dc2f99e2134fa24a58a7d8e9e7 (patch)
tree543b5bfd7af7d2e74baa62b1d5d65eb4089b893a
parentcb05afb2f95c3a31d58fa8d3d34234d0106eaa88 (diff)
downloadauthentic2-pratic-a0b156ffabba27dc2f99e2134fa24a58a7d8e9e7.zip
authentic2-pratic-a0b156ffabba27dc2f99e2134fa24a58a7d8e9e7.tar.gz
authentic2-pratic-a0b156ffabba27dc2f99e2134fa24a58a7d8e9e7.tar.bz2
load-pratic-ldif: allow modifying existing service instances
-rw-r--r--src/authentic2_pratic/management/commands/load-pratic-ldif.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/authentic2_pratic/management/commands/load-pratic-ldif.py b/src/authentic2_pratic/management/commands/load-pratic-ldif.py
index 39132f0..9295fff 100644
--- a/src/authentic2_pratic/management/commands/load-pratic-ldif.py
+++ b/src/authentic2_pratic/management/commands/load-pratic-ldif.py
@@ -148,10 +148,17 @@ class PraticLDIFParser(ldif.LDIFParser):
service = self.services[entry['cdg59serviceType'][0]]
if not service.is_global and 'service_url' not in others:
others['service_url'] = 'http://missing-url-%s.com' % others['slug']
- service_instance = ServiceInstance(
+ try:
+ service_instance = ServiceInstance.objects.get(
collectivity=collectivity,
- service=service,
- **others)
+ service=service)
+ for k, v in others.iteritems():
+ setattr(service_instance, k, v)
+ except ServiceInstance.DoesNotExist:
+ service_instance = ServiceInstance(
+ collectivity=collectivity,
+ service=service,
+ **others)
try:
service_instance.clean()
except ValidationError, e: