Permalink
Browse files

Fixes bug 991730 - Fixed custom queries. r=peterbe

  • Loading branch information...
1 parent 9674c5f commit a25634d28618c31149525a71678c98da1486d941 @adngdb adngdb committed Apr 3, 2014
@@ -27,13 +27,14 @@
class Query(ElasticSearchBase):
'''Implement the /query service with ElasticSearch. '''
+ filters = [
+ ('query', None, 'str'),
+ ('indices', None, ['list', 'str']),
+ ]
+
def get(self, **kwargs):
'''Return the result of a custom query. '''
- filters = [
- ('query', None, 'str'),
- ('indices', None, ['list', 'str']),
- ]
- params = external_common.parse_arguments(filters, kwargs)
+ params = external_common.parse_arguments(self.filters, kwargs)
if not params.query:
raise MissingArgumentError('query')
@@ -23,8 +23,8 @@ $(function () {
// Django CSRF protection
var csrftoken = $('input[name=csrfmiddlewaretoken]').val();
- function beautifulJSON(json) {
- return JSON.stringify(JSON.parse(json), null, 4);
+ function beautifulJSON(data) {
+ return JSON.stringify(data, null, 4);
}
function csrfSafeMethod(method) {
@@ -48,6 +48,7 @@ $(function () {
url: resultsURL,
data: {'query': query, 'indices': indices},
type: 'POST',
+ traditional: true,
success: function(data) {
// Render that JSON beautiful.
data = beautifulJSON(data);
@@ -72,7 +73,7 @@ $(function () {
e.preventDefault();
var query = editor.getValue();
- var indices = indicesElt.select2('data');
+ var indices = indicesElt.select2('val');
var state = {
'query': query,
'indices': indices
@@ -104,7 +105,7 @@ $(function () {
if (!jsonQuery) {
jsonQuery = defaultQuery;
}
- editorElt.html(beautifulJSON(jsonQuery));
+ editorElt.html(beautifulJSON(JSON.parse(jsonQuery)));
// Prepare the ACE editor for JSON content.
editor = ace.edit('editor');

0 comments on commit a25634d

Please sign in to comment.