diff --git a/languages/fr-fr.py b/languages/fr-fr.py index 6605af13ff5703f6c0a0df92372a36c24090c76a..a81eabc5603f441bebfcf502aac34f44eeaacc43 100644 --- a/languages/fr-fr.py +++ b/languages/fr-fr.py @@ -53,6 +53,7 @@ 'Type': 'Type', 'Volume': 'Volume', 'Year': 'Année', +'blab blab ....': 'blab blab ....', 'categories': 'catégories', 'collaborations': 'collaborations', 'countries': 'pays', diff --git a/models/widgets.py b/models/widgets.py index fea1f631d386c98d225cdf3c02e60002a3e333a3..e28c3f44f75491b2aecd8bd288f8eaafc4dbab7e 100755 --- a/models/widgets.py +++ b/models/widgets.py @@ -176,7 +176,8 @@ filters = [('year', '==', T('select publication for a given year')), ('id_teams', '==', T('select publications for a given team')), ('id_projects', '==', T('select publications for a given project')), ('id_categories', '==', T('select publications with a given category code')), - ('authors_cppm', 'contains', T('select publications for a given CPPM author'))] + ('authors_cppm', 'contains', T('select publications for a given CPPM author')), + ('countries.country', 'contains', T('blab blab ....'))] gridModifier.set_filters(*filters, plugins=['pFormToolTip'], diff --git a/modules/plugin_dbui/converter.py b/modules/plugin_dbui/converter.py index ac973632fe08a7c0d9b74aafb4904e945ad2f67f..ffd9786c2c74785be0e10bf9b3e479adbfe391bc 100644 --- a/modules/plugin_dbui/converter.py +++ b/modules/plugin_dbui/converter.py @@ -3,6 +3,8 @@ Author: R. Le Gac """ +import re + from extjs import * from gluon import current from helper import (encode_field, @@ -45,7 +47,7 @@ def _to_field(field, **kwargs): The conversion takes into account the FieldsModifier instructions. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ T = current.T @@ -132,10 +134,10 @@ def to_field(field, **kwargs): Composite fields are set using the FieldsModifer. - Return None if the field is comsumed by a CompositeField. + Return None if the field is consumed by a CompositeField. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ table = field.table @@ -253,7 +255,7 @@ def to_formPanel(table, **kwargs): The conversion takes into account the form modifier instructions. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ tablename = table._tablename @@ -281,7 +283,7 @@ def to_gridColumn(field, **kwargs): The conversion takes into account the grid modifier instructions. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ T = current.T @@ -371,8 +373,18 @@ def to_gridFilter(table, **kwargs): Return an empty dictionary if not defined ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. + + FILTER RULE: + A tuple of 3 string (field1, operator, comment). + Field1 is the name of a field belonging to the table. + Valid operators are defined in Dbsvc._encode_query. + + A more elaborate filter rule allows to filter on any foreign field. + the syntax is (table2.field1, operator, comments). + Rules are store in modifier section grid_filters. + """ T = current.T tablename = table._tablename @@ -388,7 +400,19 @@ def to_gridFilter(table, **kwargs): di = GridFilter(title=T('Filter %s' % tablename)) for (fieldname, operator, comment) in grid_filters.filters: - field = table[fieldname] + + # filter rule dealing with any foreign field + m = re.match(r"(\w+)\.(\w+)", fieldname) + if m: + ktablename = m.group(1) + kfieldname = m.group(2) + field = table._db[ktablename][kfieldname] + name = '[%s.%s]' % (ktablename, kfieldname) + + # basic filter rule + else: + field = table[fieldname] + name = '[%s.%s]' % (tablename, fieldname) # get the standard configuration for the field cfg = to_field(field) @@ -402,8 +426,8 @@ def to_gridFilter(table, **kwargs): if cfg['xtype'] == 'textarea': cfg['xtype'] = 'textfield' - # prepare the name for the where close - cfg['name'] = '[%s.%s]' % (tablename, fieldname) + # prepare the name for the where close [table.field] + cfg['name'] = name # store information to customize the filter cfg['filterComment'] = comment @@ -430,7 +454,7 @@ def to_gridPanel(table, **kwargs): The conversion takes into account the grid modifier instructions. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ tablename = table._tablename @@ -464,7 +488,7 @@ def to_jsonstore(table, **kwargs): """Convert a gluon.dal.Table into an App.data.DirectStore. ExtJS configuration parameters are applied in the following order: - constructor, modifers, keyword arguments. + constructor, modifiers, keyword arguments. """ db = table._db