Repository: django-cms/django-filer

Issue:
make_folder without  _popup= argument causes a 500 error
The make_folder view generates a 500 error when no arguments are passed to it (specifically the _popup=1).  I believe that this is because the admin/filer/folder/new_folder_form.html template, which inherits admin/change_form.html, does not have opts defined in it, and thus the reverse app_list in that template fails: 

https://github.com/django/django/blob/1.6.7/django/contrib/admin/templates/admin/change_form.html#L19

Django version 1.6.7
django-filer-0.9.6

https://github.com/stefanfoulis/django-filer/blob/0.9.7/filer/views.py#L85

Generates Error

```
http://localhost:8000/admin/filer/folder/make_folder/
```

No Error

```
http://localhost:8000/admin/filer/folder/make_folder/?parent_id=&_popup=1
```

Environment:

```
Request Method: GET
Request URL: http://localhost:8000/admin/filer/folder/make_folder/

Django Version: 1.6.7
Python Version: 2.7.6

Traceback:
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  198.             return view(request, *args, **kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/filer/views.py" in make_folder
  120.     }, context_instance=RequestContext(request))
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  169.         return t.render(context_instance)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  123.         return compiled_parent._render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  305.                 return nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render
  840.                 bit = self.render_node(node, context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/base.py" in render_node
  854.         return node.render(context)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  447.                         six.reraise(*exc_info)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  433.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
  536.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/iscape/sites/mysite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
  456.                              (lookup_view_s, args, kwargs, len(patterns), patterns))

Exception Type: NoReverseMatch at /admin/filer/folder/make_folder/
Exception Value: Reverse for 'app_list' with arguments '()' and keyword arguments '{u'app_label': ''}' not found. 1 pattern(s) tried: [u'admin/(?P<app_label>\\w+)/$']
```



Discussion:
@imagescape have you found a solution for this in the meantime?


Resolving patch:
diff --git a/filer/views.py b/filer/views.py
--- a/filer/views.py
+++ b/filer/views.py
@@ -113,6 +113,7 @@ def make_folder(request, folder_id=None):
     else:
         new_folder_form = NewFolderForm()
     return render_to_response('admin/filer/folder/new_folder_form.html', {
+        'opts': Folder._meta,
         'new_folder_form': new_folder_form,
         'is_popup': popup_status(request),
         'select_folder': selectfolder_status(request),


Test patch:
diff --git a/filer/tests/admin.py b/filer/tests/admin.py
--- a/filer/tests/admin.py
+++ b/filer/tests/admin.py
@@ -36,6 +36,10 @@ def test_filer_make_root_folder_get(self):
         response = self.client.get(reverse('admin:filer-directory_listing-make_root_folder')+"?_popup=1")
         self.assertEqual(response.status_code, 200)
 
+    def test_filer_make_root_folder_get_no_param(self):
+        response = self.client.get(reverse('admin:filer-directory_listing-make_root_folder'))
+        self.assertEqual(response.status_code, 200)
+
     def test_filer_make_root_folder_post(self):
         FOLDER_NAME = "root folder 1"
         self.assertEqual(Folder.objects.count(), 0)