Skip to content

Commit

Permalink
Fixed file selection after using search box (CKEditor).
Browse files Browse the repository at this point in the history
Added CKEditor params to the search form hidden inputs so they persist
after searching.
  • Loading branch information
timgraham committed Mar 4, 2014
1 parent dcc6842 commit 5910bd1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Patrick Kranzlmueller <[email protected]>
Axel Swoboda <[email protected]>
Klemens Mantzos <[email protected]>
Vaclav Mikolasek <[email protected]>
Vaclav Mikolasek <[email protected]>
Tim Graham <[email protected]>
4 changes: 4 additions & 0 deletions filebrowser/templates/filebrowser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
{% if query.type %}<input type="hidden" name="type" value="{{ query.type }}" />{% endif %}
{% if query.format %}<input type="hidden" name="format" value="{{ query.format }}" />{% endif %}
{% if query.dir %}<input type="hidden" name="dir" value="{{ query.dir|urlencode }}" />{% endif %}
{% ifequal query.pop '3' %} {# Custom CKEditor fields #}
{% if query.CKEditor %}<input type="hidden" name="CKEditor" value="{{ query.CKEditor }}" />{% endif %}
{% if query.CKEditorFuncNum %}<input type="hidden" name="CKEditorFuncNum" value="{{ query.CKEditorFuncNum }}" />{% endif %}
{% endifequal %}
<button class="grp-search-button" type="submit" value="">&nbsp;</button>
</form>
</div>
Expand Down
21 changes: 21 additions & 0 deletions filebrowser/tests/test_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ def test_browse(test):
test.assertTrue(test.site.directory == response.context['filebrowser_site'].directory)


def test_ckeditor_params_in_search_form(test):
"""
The CKEditor GET params must be included in the search form as hidden
inputs so they persist after searching.
"""
url = reverse('%s:fb_browse' % test.site_name)
response = test.c.get(url, {
'pop': '3',
'type': 'image',
'CKEditor': 'id_body',
'CKEditorFuncNum': '1',
})

test.assertTrue(response.status_code == 200)
test.assertContains(response, '<input type="hidden" name="pop" value="3" />')
test.assertContains(response, '<input type="hidden" name="type" value="image" />')
test.assertContains(response, '<input type="hidden" name="CKEditor" value="id_body" />')
test.assertContains(response, '<input type="hidden" name="CKEditorFuncNum" value="1" />')


def test_createdir(test):
"""
Check the createdir view functions as expected. Creates a new tmp directory
Expand Down Expand Up @@ -378,6 +398,7 @@ def runTest(self):
self.assertTrue(response)
# Execute tests
test_browse(self)
test_ckeditor_params_in_search_form(self)
test_createdir(self)
test_upload(self)
test_do_upload(self)
Expand Down

0 comments on commit 5910bd1

Please sign in to comment.