Skip to content
Snippets Groups Projects
Commit c64a45b9 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Run pylint checker on plugin_dbui/converter.py

parent bd40af67
No related branches found
No related tags found
2 merge requests!15Release 0.7.3,!1014 pylint jslint
......@@ -4,8 +4,32 @@
import gluon.dal
import re
from extjs import *
from extjs import (Base,
CheckBox,
ComboBox,
DirectStore,
FieldContainer,
FieldDate,
FieldDict,
FieldList,
FieldNumber,
FieldSet,
FieldText,
FieldTextArea,
FieldTime,
FormPanel,
GridColumn,
GridColumnModel,
GridFilter,
GridPanel,
GridRowNumberer,
GridTemplateColumn,
GridWithFilter,
Model,
PanelWithUrlSelector)
from gluon import current
from gluon.tools import PluginManager
from gridmodifier import ROW_NUMBERING
from helper import (encode_field,
get_field_validators,
......@@ -18,21 +42,21 @@ from mapper import map_default
# Associated gluon.dal.field type with an ExtJS widget
# The dictionary contains configuration parameters of the Ext JS widget
FTYPE_TO_XTYPE = {'boolean': (CheckBox, {}), \
'date': (FieldDate, {'format': 'Y-m-d'}), \
'datetime': (FieldDate, {'format': 'Y-m-d H:i:s'}), \
'double': (FieldNumber, {'decimalPrecision':2,
'decimalSeparator': '.'}), \
'id': (FieldText, {}), \
'integer': (FieldNumber, {}), \
FTYPE_TO_XTYPE = {'boolean': (CheckBox, {}),
'date': (FieldDate, {'format': 'Y-m-d'}),
'datetime': (FieldDate, {'format': 'Y-m-d H:i:s'}),
'double': (FieldNumber, {'decimalPrecision': 2,
'decimalSeparator': '.'}),
'id': (FieldText, {}),
'integer': (FieldNumber, {}),
'json': (FieldDict, {}),
'list:string': (FieldList, {}), \
'list:integer': (FieldTextArea, {}), \
'password': (FieldText, {'inputType': 'password'}), \
'reference': (ComboBox, {}), \
'string': (FieldText, {}), \
'text': (FieldTextArea, {}), \
'time': (FieldTime, {}), \
'list:string': (FieldList, {}),
'list:integer': (FieldTextArea, {}),
'password': (FieldText, {'inputType': 'password'}),
'reference': (ComboBox, {}),
'string': (FieldText, {}),
'text': (FieldTextArea, {}),
'time': (FieldTime, {}),
'upload': (FieldText, {'inputType': 'file'})}
......@@ -240,7 +264,8 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs):
cfg.update(composite_fields[field.name].extjs)
# an embedded field already used in a composite field
elif composite and composite_fields and field.name in composite_fields.others:
elif composite \
and composite_fields and field.name in composite_fields.others:
cfg = None
# a basic field
......@@ -641,11 +666,11 @@ def to_gridPanel(table, **kwargs):
# configuration option from the keyword arguments
cfg.update(kwargs)
# grid with filter
filter = to_gridFilter(table)
if filter:
# grid with grid_filter
grid_filter = to_gridFilter(table)
if grid_filter:
cfg = GridWithFilter(panelItems=dict(cfg),
selectorItems=filter)
selectorItems=grid_filter)
if tablename in modifier_grids:
cfg.update(modifier_grids[tablename].grid_with_filter.extjs)
......@@ -672,7 +697,6 @@ def to_jsonstore(table, **kwargs):
DirectStore
"""
db = table._db
tablename = table._tablename
# NOTE: the configuration option extraParams defined the
......@@ -710,7 +734,8 @@ def to_jsonstore(table, **kwargs):
# in form and in grid.
if is_foreign_field(field):
if 'where' not in base_params: base_params['where'] = []
if 'where' not in base_params:
base_params['where'] = []
# the foreign field
k_tablename, k_fieldname, k_key = get_foreign_field(field)
......@@ -729,17 +754,17 @@ def to_jsonstore(table, **kwargs):
for el in modifier_stores[tablename].orderby:
if isinstance(el, gluon.dal.Field):
field, dir = el, 'ASC'
field, direction = el, 'ASC'
elif isinstance(el, gluon.dal.Expression):
field, dir = el.first, 'DESC'
field, direction = el.first, 'DESC'
base_params['orderby'].append([field.tablename, field.name, dir])
li = [field.tablename, field.name, direction]
base_params['orderby'].append(li)
# Ext JS configuration option from the modifier
cfg.update(modifier_stores[tablename].extjs)
# Ext JS configuration options from the keyword arguments
cfg.update(kwargs)
......@@ -773,7 +798,8 @@ def to_model(table):
# the default value can be a callable.
# that case makes no sense on the client side
# in addition the JSON dumps will failed
# therefore the default value are limited to types which can be JSONify.
# therefore the default value are limited to types which
# can be JSONifyied.
default = field.default
if default and isinstance(default, JSON_TYPES):
field_cfg['defaultValue'] = default
......@@ -896,4 +922,4 @@ def to_viewport(**kwargs):
# configuration options from the keyword arguments
cfg.update(kwargs)
return cfg
\ No newline at end of file
return cfg
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment