Comment 3 for bug 1375758

Revision history for this message
Daniele ViganĂ² (daniele-vigano) wrote :

The problem is caused when we try to rename the Maps using https://github.com/gem/oq-platform/blob/master/openquakeplatform/openquakeplatform/maps_viewer/management/commands/map_title.py#L28

For example, for GHEC both GHEC map and a FE layer have id = 2. The code changes the title to both.

We tried using Map instead of ResourceBase but the problem is stille there. It looks like that the root cause is stille an issue with IDs and fixtures:

from geonode.maps.models import Map

class Command(BaseCommand):

    def handle(self, *args, **options):
     titles = ((1, "Instrumental Seismic Catalogue"), (2, "Global Historic Catalogue"), (3, "Global Active Faults"))
     for id, name in titles:
         table_row = Map.objects.get(id=id)
         table_row.title = name
         table_row.save()

If we try to change the layer or map name in the Django admin console with get an ugly error related to keys:

Traceback:
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115. response = callback(request, *callback_args, **callback_kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  372. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  202. return view(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  25. return bound_func(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  21. return func(self, *args2, **kwargs2)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
  223. return func(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
  1100. queryset=inline.queryset(request))
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in __init__
  720. queryset=qs, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in __init__
  441. super(BaseModelFormSet, self).__init__(**defaults)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/formsets.py" in __init__
  56. self._construct_forms()
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms
  124. self.forms.append(self._construct_form(i))
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
  729. form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
  460. pk = self.data[pk_key]
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/datastructures.py" in __getitem__
  295. raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))

Exception Type: MultiValueDictKeyError at /admin/maps/map/2/