changeset 140:f3ee09b031dd

Simpliy query builder a tiny bit.
author Daniele Nicolodi <daniele@grinta.net>
date Sun, 16 Oct 2011 23:38:32 +0200
parents 347b29cb9332
children 2827664bb785
files src/ltpdarepo/static/querywidget.js src/ltpdarepo/views/browse.py
diffstat 2 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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: