# HG changeset patch # User Daniele Nicolodi # Date 1318801112 -7200 # Node ID f3ee09b031dde5de535d6c0667697009daaec5a8 # Parent 347b29cb93320803111b9fb0402a1bba592b9845 Simpliy query builder a tiny bit. diff -r 347b29cb9332 -r f3ee09b031dd src/ltpdarepo/static/querywidget.js --- a/src/ltpdarepo/static/querywidget.js Sun Oct 16 23:37:19 2011 +0200 +++ b/src/ltpdarepo/static/querywidget.js Sun Oct 16 23:38:32 2011 +0200 @@ -31,17 +31,15 @@ // create label $.querywidget.createQueryLabel = function (index) { - var name = $.querywidget.config.indexes[index].name; - return $(document.createElement('span')).html(name).addClass('querywidget field'); + return $(document.createElement('span')).html(index).addClass('querywidget field'); }; // create field name $.querywidget.createQueryField = function (index) { - var value = $.querywidget.config.indexes[index].value; return $(document.createElement('input')).attr({ 'type': 'hidden', 'name': 'field', - 'value': value}) + 'value': index}) }; // create operator select menu diff -r 347b29cb9332 -r f3ee09b031dd src/ltpdarepo/views/browse.py --- a/src/ltpdarepo/views/browse.py Sun Oct 16 23:37:19 2011 +0200 +++ b/src/ltpdarepo/views/browse.py Sun Oct 16 23:38:32 2011 +0200 @@ -24,7 +24,7 @@ FIELDS = ('id', 'name', 'type', 'quantity', 'keywords', 'submitted', 'title', 'description',) -EXTRA = ('analysis', 'author', 'additional_authors', 'comments', 'reference_ids', 'created', ) +EXTRA = ('analysis', 'author', 'additional authors', 'comments', 'reference ids', 'created', ) MORE = ('version', 'ip', 'hostname', 'os', 'validated', 'vdate') TIMESERIESFIELDS = ('id', 'name', 't0', 'nsecs', 'quantity', 'keywords', 'title', 'description') @@ -43,9 +43,9 @@ ('description', 'objmeta.experiment_desc'), ('analysis', 'objmeta.analysis_desc'), ('author', 'objmeta.author'), - ('additional_authors', 'objmeta.additional_authors'), + ('additional authors', 'objmeta.additional_authors'), ('comments', 'objmeta.additional_comments'), - ('reference_ids', 'objmeta.reference_ids'), + ('reference ids', 'objmeta.reference_ids'), ('created', 'objmeta.created')]) def __init__(self, database): @@ -198,10 +198,7 @@ for column, kind, values in [self.parse(x) for x in curs.fetchall()]: name = mapping.get(column) if name: - indexes.append(Index(name=name.replace('_', ' '), - value=name, - column='.'.join(('objmeta', column)), - type=kind, + indexes.append(Index(name=name, type=kind, operators=Indexes.operators[kind], values=values)) @@ -295,7 +292,7 @@ value = validate(value) # add to query parameters vals.append(value) - query.append('%s %s %%s' % (index.column, op)) + query.append('%s %s %%s' % (self.columns[field], op)) except ValueError: error = True finally: