diff options
Diffstat (limited to 'chimere/admin.py')
| -rw-r--r-- | chimere/admin.py | 19 | 
1 files changed, 16 insertions, 3 deletions
diff --git a/chimere/admin.py b/chimere/admin.py index 4e175aa..8fe2b77 100644 --- a/chimere/admin.py +++ b/chimere/admin.py @@ -112,9 +112,21 @@ def managed_modified(modeladmin, request, queryset):      if request.POST.get('rapprochement'):          couple = [(item, item_ref)]          if hasattr(item, 'associated_marker'): -            couple.append((item.associated_marker, item_ref.associated_marker)) -        for it, it_ref in couple: -            for k in request.POST: +            couple.append((item.associated_marker.all()[0], +                           item_ref.associated_marker.all()[0])) +        updated_keys = request.POST +        updated_keys.pop('action') +        updated_keys.pop('rapprochement') +        updated_keys.pop('index') +        updated_keys.pop('_selected_action') +        for idx, cpl in enumerate(couple): +            it, it_ref = cpl +            # don't copy geometry of associated items +            if idx: +                for k in ('route', 'point'): +                    if k in updated_keys: +                        updated_keys.pop(k) +            for k in updated_keys:                  if not request.POST[k]:                      continue                  if hasattr(it_ref, k): @@ -124,6 +136,7 @@ def managed_modified(modeladmin, request, queryset):                          for val in getattr(it, k).all():                              c_value.add(val)                      else: +                        setattr(it_ref, k, getattr(it, k))                          it_ref.save()                  elif k.startswith('property_'):                      try:  | 
