Repository: django-cms/django-filer

Issue:
KeyError when saving folder object from popup
A KeyError 'location' occurs when saving a folder object from a file-chooser popup (popup opened from admin widget).

``` python
Internal Server Error: /admin/filer/folder/1/
Traceback (most recent call last):
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1519, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 30, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
    return func(*args, **kwargs)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1475, in changeform_view
    return self.response_change(request, new_object)
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/filer/admin/folderadmin.py", line 127, in response_change
    if r['Location']:
  File "/Users/rick/Development/project/venv/lib/python2.7/site-packages/django/http/response.py", line 208, in __getitem__
    return self._headers[header.lower()][1]
KeyError: u'location'
```

Appears to be the same as #532, but for Folders.



Discussion:

Resolving patch:
diff --git a/filer/admin/folderadmin.py b/filer/admin/folderadmin.py
--- a/filer/admin/folderadmin.py
+++ b/filer/admin/folderadmin.py
@@ -124,7 +124,7 @@ def response_change(self, request, obj):
         """
         r = super(FolderAdmin, self).response_change(request, obj)
         ## Code borrowed from django ModelAdmin to determine changelist on the fly
-        if r['Location']:
+        if 'Location' in r and r['Location']:
             # it was a successful save
             if (r['Location'] in ['../'] or
                     r['Location'] == self._get_post_url(obj)):


Test patch: